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.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, attributes) ⇒ ObjectBuilder

Returns a new instance of ObjectBuilder.


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

def initialize(klass, attributes)
  super

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

Class Method Details

.build(*args) ⇒ Object


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

def self.build(*args)
  ::Project.transaction do
    super
  end
end

Instance Method Details

#findObject


29
30
31
32
33
# File 'lib/gitlab/import_export/project/object_builder.rb', line 29

def find
  return if epic? && group.nil?

  super
end