Welcome to mirror list, hosted at ThFree Co, Russian Federation.

project_import_data.rb « models « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 79efb40305804a79d9fd6fb51a9e391c6c03373d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# == Schema Information
#
# Table name: project_import_data
#
#  id         :integer          not null, primary key
#  project_id :integer
#  data       :text
#

require 'carrierwave/orm/activerecord'
require 'file_size_validator'

class ProjectImportData < ActiveRecord::Base
  belongs_to :project
  attr_encrypted :credentials,
                 key: Gitlab::Application.secrets.db_key_base,
                 marshal: true,
                 encode: true,
                 mode: :per_attribute_iv_and_salt

  serialize :data, JSON

  validates :project, presence: true

  before_validation :symbolize_credentials

  def symbolize_credentials
    # bang doesn't work here - attr_encrypted makes it not to work
    self.credentials = self.credentials.deep_symbolize_keys unless self.credentials.blank?
  end
end