Class: Gitlab::LegacyGithubImport::BaseFormatter
- Inherits:
-
Object
- Object
- Gitlab::LegacyGithubImport::BaseFormatter
- Defined in:
- lib/gitlab/legacy_github_import/base_formatter.rb
Direct Known Subclasses
BranchFormatter, CommentFormatter, IssuableFormatter, LabelFormatter, MilestoneFormatter, ReleaseFormatter
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#formatter ⇒ Object
readonly
Returns the value of attribute formatter.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#raw_data ⇒ Object
readonly
Returns the value of attribute raw_data.
Instance Method Summary collapse
-
#create! ⇒ Object
rubocop: disable CodeReuse/ActiveRecord.
-
#initialize(project, raw_data, client = nil) ⇒ BaseFormatter
constructor
A new instance of BaseFormatter.
-
#url ⇒ Object
rubocop: enable CodeReuse/ActiveRecord.
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
#client ⇒ Object (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 |
#formatter ⇒ Object (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 |
#project ⇒ Object (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_data ⇒ Object (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 |
#url ⇒ Object
rubocop: enable CodeReuse/ActiveRecord
25 26 27 |
# File 'lib/gitlab/legacy_github_import/base_formatter.rb', line 25 def url raw_data[:url] || '' end |