Class: HammerCLIForeman::AddAssociatedCommand

Inherits:
AssociatedCommand show all
Defined in:
lib/hammer_cli_foreman/commands.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AssociatedCommand

associated_identifiers, associated_resource, #associated_resource, declared_associated_identifiers, #get_current_ids, #get_required_id, #initialize, #request_params, #setup_associated_identifier_options, #validate_options

Methods inherited from WriteCommand

#send_request, #success_message_params

Constructor Details

This class inherits a constructor from HammerCLIForeman::AssociatedCommand

Class Method Details

.command_name(name = nil) ⇒ Object



246
247
248
# File 'lib/hammer_cli_foreman/commands.rb', line 246

def self.command_name(name=nil)
  super(name) || (associated_resource ? "add_"+associated_resource.name : nil)
end

.desc(desc = nil) ⇒ Object



250
251
252
# File 'lib/hammer_cli_foreman/commands.rb', line 250

def self.desc(desc=nil)
  "Associate a resource"
end

Instance Method Details

#get_new_idsObject



254
255
256
257
258
259
260
# File 'lib/hammer_cli_foreman/commands.rb', line 254

def get_new_ids
  ids = get_current_ids
  required_id = get_required_id

  ids << required_id unless ids.include? required_id
  ids
end