debian-mirror-gitlab/lib/gitlab/github_import/label_formatter.rb

38 lines
700 B
Ruby
Raw Normal View History

2016-06-02 11:05:42 +05:30
module Gitlab
module GithubImport
class LabelFormatter < BaseFormatter
def attributes
{
project: project,
title: title,
color: color
}
end
2016-11-03 12:29:30 +05:30
def project_association
:labels
end
2016-09-29 09:46:39 +05:30
def create!
2016-11-03 12:29:30 +05:30
params = attributes.except(:project)
service = ::Labels::FindOrCreateService.new(nil, project, params)
label = service.execute(skip_authorization: true)
raise ActiveRecord::RecordInvalid.new(label) unless label.persisted?
label
2016-09-29 09:46:39 +05:30
end
2016-06-02 11:05:42 +05:30
private
def color
"##{raw_data.color}"
end
def title
raw_data.name
end
end
end
end