project_import_data.rb 661 Bytes
Newer Older
1 2 3 4
require 'carrierwave/orm/activerecord'

class ProjectImportData < ActiveRecord::Base
  belongs_to :project
5 6 7 8
  attr_encrypted :credentials,
                 key: Gitlab::Application.secrets.db_key_base,
                 marshal: true,
                 encode: true,
9 10
                 mode: :per_attribute_iv_and_salt,
                 algorithm: 'aes-256-cbc'
11

12 13 14
  serialize :data, JSON

  validates :project, presence: true
James Lopez's avatar
James Lopez committed
15

16 17 18
  before_validation :symbolize_credentials

  def symbolize_credentials
19
    # bang doesn't work here - attr_encrypted makes it not to work
20
    self.credentials = self.credentials.deep_symbolize_keys unless self.credentials.blank?
James Lopez's avatar
James Lopez committed
21
  end
22
end