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

alias_name_for_resource, build_options, connection_name, #customized_options, #dependency_resolver, dependency_resolver, #exception_handler_class, #get_identifier, #get_resource_id, #get_resource_ids, #request_params, #resolver, resolver, resource_alias_name_mapping, resource_config, resource_name_mapping, #searchables, searchables, #send_request, #transform_format

Class Method Details

.command_name(name = nil) ⇒ Object



534
535
536
# File 'lib/hammer_cli_foreman/commands.rb', line 534

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

.create_option_builderObject



538
539
540
541
542
# File 'lib/hammer_cli_foreman/commands.rb', line 538

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

.inherited(child) ⇒ Object



544
545
546
# File 'lib/hammer_cli_foreman/commands.rb', line 544

def self.inherited(child)
  child.success_message_for(:nothing_to_do, _('Nothing to update.'))
end

Instance Method Details

#clean_up_contextObject



548
549
550
551
# File 'lib/hammer_cli_foreman/commands.rb', line 548

def clean_up_context
  super
  context.delete(:action_message)
end

#method_options_for_params(params, options) ⇒ Object



557
558
559
560
561
562
563
564
565
566
567
# File 'lib/hammer_cli_foreman/commands.rb', line 557

def method_options_for_params(params, options)
  opts = super
  # overwrite searchables with correct values
  searchables.for(resource).each do |s|
    next unless params.map(&:name).include?(s.name)

    new_value = get_option_value("new_#{s.name}")
    opts[s.name] = new_value unless new_value.nil?
  end
  opts
end

#success_messageObject



553
554
555
# File 'lib/hammer_cli_foreman/commands.rb', line 553

def success_message
  success_message_for(context[:action_message] || :default)
end