Class: Gitlab::LegacyGithubImport::BaseFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/legacy_github_import/base_formatter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project, raw_data, client = nil) ⇒ BaseFormatter

Returns a new instance of BaseFormatter.


8
9
10
11
12
13
# File 'lib/gitlab/legacy_github_import/base_formatter.rb', line 8

def initialize(project, raw_data, client = nil)
  @project = project
  @raw_data = raw_data
  @client = client
  @formatter = Gitlab::ImportFormatter.new
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.


6
7
8
# File 'lib/gitlab/legacy_github_import/base_formatter.rb', line 6

def client
  @client
end

#formatterObject (readonly)

Returns the value of attribute formatter.


6
7
8
# File 'lib/gitlab/legacy_github_import/base_formatter.rb', line 6

def formatter
  @formatter
end

#projectObject (readonly)

Returns the value of attribute project.


6
7
8
# File 'lib/gitlab/legacy_github_import/base_formatter.rb', line 6

def project
  @project
end

#raw_dataObject (readonly)

Returns the value of attribute raw_data.


6
7
8
# File 'lib/gitlab/legacy_github_import/base_formatter.rb', line 6

def raw_data
  @raw_data
end

Instance Method Details

#create!Object

rubocop: disable CodeReuse/ActiveRecord


16
17
18
19
20
21
22
# File 'lib/gitlab/legacy_github_import/base_formatter.rb', line 16

def create!
  association = project.public_send(project_association) # rubocop:disable GitlabSecurity/PublicSend

  association.find_or_create_by!(find_condition) do |record|
    record.attributes = attributes
  end
end

#urlObject

rubocop: enable CodeReuse/ActiveRecord


25
26
27
# File 'lib/gitlab/legacy_github_import/base_formatter.rb', line 25

def url
  raw_data.url || ''
end