Class: Packages::Npm::CreateTagService

Inherits:
Object
  • Object
show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
app/services/packages/npm/create_tag_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

#initialize(package, tag_name) ⇒ CreateTagService

Returns a new instance of CreateTagService.


9
10
11
12
# File 'app/services/packages/npm/create_tag_service.rb', line 9

def initialize(package, tag_name)
  @package = package
  @tag_name = tag_name
end

Instance Attribute Details

#packageObject (readonly)

Returns the value of attribute package


7
8
9
# File 'app/services/packages/npm/create_tag_service.rb', line 7

def package
  @package
end

#tag_nameObject (readonly)

Returns the value of attribute tag_name


7
8
9
# File 'app/services/packages/npm/create_tag_service.rb', line 7

def tag_name
  @tag_name
end

Instance Method Details

#executeObject


14
15
16
17
18
19
20
21
# File 'app/services/packages/npm/create_tag_service.rb', line 14

def execute
  if existing_tag.present?
    existing_tag.update_column(:package_id, package.id)
    existing_tag
  else
    package.tags.create!(name: tag_name)
  end
end