Class: Gitlab::Ci::Pipeline::Seed::Processable::ResourceGroup

Inherits:
Base
  • Object
show all
Includes:
Utils::StrongMemoize
Defined in:
lib/gitlab/ci/pipeline/seed/processable/resource_group.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#attributes, #errors, #included?

Constructor Details

#initialize(processable, resource_group_key) ⇒ ResourceGroup

Returns a new instance of ResourceGroup.



13
14
15
16
# File 'lib/gitlab/ci/pipeline/seed/processable/resource_group.rb', line 13

def initialize(processable, resource_group_key)
  @processable = processable
  @resource_group_key = resource_group_key
end

Instance Attribute Details

#processableObject (readonly)

Returns the value of attribute processable.



11
12
13
# File 'lib/gitlab/ci/pipeline/seed/processable/resource_group.rb', line 11

def processable
  @processable
end

#resource_group_keyObject (readonly)

Returns the value of attribute resource_group_key.



11
12
13
# File 'lib/gitlab/ci/pipeline/seed/processable/resource_group.rb', line 11

def resource_group_key
  @resource_group_key
end

Instance Method Details

#to_resourceObject



18
19
20
21
22
23
24
25
# File 'lib/gitlab/ci/pipeline/seed/processable/resource_group.rb', line 18

def to_resource
  return unless resource_group_key.present?

  resource_group = processable.project.resource_groups
    .safe_find_or_create_by(key: expanded_resource_group_key)

  resource_group if resource_group.persisted?
end