Class: Gitlab::ImportExport::Project::ObjectBuilder

Inherits:
Base::ObjectBuilder show all
Defined in:
lib/gitlab/import_export/project/object_builder.rb

Overview

Given a class, it finds or creates a new object (initializes in the case of Label) at group or project level. If it does not exist in the group, it creates it at project level.

Example:

`ObjectBuilder.build(Label, label_attributes)`
 finds or initializes a label with the given attributes.

It also adds some logic around Group Labels/Milestones for edge cases.

Instance Method Summary collapse

Methods inherited from Base::ObjectBuilder

build

Constructor Details

#initialize(klass, attributes) ⇒ ObjectBuilder

Returns a new instance of ObjectBuilder.



16
17
18
19
20
21
# File 'lib/gitlab/import_export/project/object_builder.rb', line 16

def initialize(klass, attributes)
  super

  @group = @attributes['group']
  @project = @attributes['project']
end

Instance Method Details

#findObject



23
24
25
26
27
28
29
30
# File 'lib/gitlab/import_export/project/object_builder.rb', line 23

def find
  return if group_relation_without_group?
  return find_diff_commit_user if diff_commit_user?
  return find_diff_commit if diff_commit?
  return find_work_item_type if work_item_type?

  super
end