Class: HammerCLIForeman::UpdateCommand

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

build_options, connection_name, #customized_options, #dependency_resolver, dependency_resolver, #get_identifier, #get_resource_id, #request_params, resolver, #resolver, resource_config, resource_name_mapping, #searchables, searchables, #send_request

Class Method Details

.command_name(name = nil) ⇒ Object



337
338
339
# File 'lib/hammer_cli_foreman/commands.rb', line 337

def self.command_name(name=nil)
  super(name) || "update"
end

.create_option_builderObject



341
342
343
344
345
# File 'lib/hammer_cli_foreman/commands.rb', line 341

def self.create_option_builder
  builder = super
  builder.builders << SearchablesUpdateOptionBuilder.new(resource, searchables) if resource_defined?
  builder
end

Instance Method Details

#method_options_for_params(params, include_nil = true) ⇒ Object



347
348
349
350
351
352
353
354
355
# File 'lib/hammer_cli_foreman/commands.rb', line 347

def method_options_for_params(params, include_nil=true)
  opts = super
  # overwrite searchables with correct values
  searchables.for(resource).each do |s|
    new_value = get_option_value("new_#{s.name}")
    opts[s.name] = new_value unless new_value.nil?
  end
  opts
end