Class: Gitlab::LegacyGithubImport::LabelFormatter

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

Instance Attribute Summary

Attributes inherited from BaseFormatter

#client, #formatter, #project, #raw_data

Instance Method Summary collapse

Methods inherited from BaseFormatter

#initialize, #url

Constructor Details

This class inherits a constructor from Gitlab::LegacyGithubImport::BaseFormatter

Instance Method Details

#attributesObject


6
7
8
9
10
11
12
# File 'lib/gitlab/legacy_github_import/label_formatter.rb', line 6

def attributes
  {
    project: project,
    title: title,
    color: color
  }
end

#create!Object

Raises:

  • (ActiveRecord::RecordInvalid)

18
19
20
21
22
23
24
25
26
# File 'lib/gitlab/legacy_github_import/label_formatter.rb', line 18

def create!
  params  = attributes.except(:project)
  service = ::Labels::FindOrCreateService.new(nil, project, params)
  label   = service.execute(skip_authorization: true)

  raise ActiveRecord::RecordInvalid, label unless label.persisted?

  label
end

#project_associationObject


14
15
16
# File 'lib/gitlab/legacy_github_import/label_formatter.rb', line 14

def project_association
  :labels
end