Class: Gitlab::ImportExport::Base::ObjectBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/import_export/base/object_builder.rb

Direct Known Subclasses

Group::ObjectBuilder, Project::ObjectBuilder

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
28
29
30
# File 'lib/gitlab/import_export/base/object_builder.rb', line 22

def initialize(klass, attributes)
  @klass = klass.ancestors.include?(Label) ? Label : klass
  @attributes = attributes

  if Gitlab::SafeRequestStore.active?
    @lru_cache = cache_from_request_store
    @cache_key = [klass, attributes]
  end
end

Class Method Details

.build(*args) ⇒ Object


18
19
20
# File 'lib/gitlab/import_export/base/object_builder.rb', line 18

def self.build(*args)
  new(*args).find
end

Instance Method Details

#findObject


32
33
34
35
36
# File 'lib/gitlab/import_export/base/object_builder.rb', line 32

def find
  find_with_cache do
    find_object || klass.create(prepare_attributes)
  end
end