Class: HammerCLIForeman::Parameter::AbstractParameterCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/hammer_cli_foreman/parameter.rb

Direct Known Subclasses

DeleteCommand, SetCommand

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_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

.create_option_builderObject



39
40
41
42
43
44
45
# File 'lib/hammer_cli_foreman/parameter.rb', line 39

def self.create_option_builder
  builder = super
  builder.builders = [
    DependentSearchablesOptionBuilder.new(resource, searchables)
  ]
  builder
end

.parameter_resourceObject



11
12
13
# File 'lib/hammer_cli_foreman/parameter.rb', line 11

def self.parameter_resource
  HammerCLIForeman.foreman_resource!(:parameters)
end

Instance Method Details

#base_action_paramsObject



33
34
35
36
37
# File 'lib/hammer_cli_foreman/parameter.rb', line 33

def base_action_params
  {
    "#{resource.singular_name}_id" => get_identifier
  }
end

#get_identifierObject



19
20
21
22
# File 'lib/hammer_cli_foreman/parameter.rb', line 19

def get_identifier
  @identifier ||= get_resource_id(resource, :scoped => true)
  @identifier
end

#get_parameter_identifierObject



24
25
26
27
28
29
30
31
# File 'lib/hammer_cli_foreman/parameter.rb', line 24

def get_parameter_identifier
  if @parameter_identifier.nil?
    opts = all_options
    opts[HammerCLI.option_accessor_name("#{resource.singular_name}_id")] ||= get_identifier
    @parameter_identifier = resolver.send("#{parameter_resource.singular_name}_id", opts)
  end
  @parameter_identifier
end

#parameter_resourceObject



15
16
17
# File 'lib/hammer_cli_foreman/parameter.rb', line 15

def parameter_resource
  self.class.parameter_resource
end