Class: HammerCLIForeman::OptionSources::NewParams
- Inherits:
-
HammerCLI::Options::Sources::Base
- Object
- HammerCLI::Options::Sources::Base
- HammerCLIForeman::OptionSources::NewParams
- Defined in:
- lib/hammer_cli_foreman/option_sources/new_params.rb
Instance Method Summary collapse
- #get_options(_defined_options, result) ⇒ Object
-
#initialize(command) ⇒ NewParams
constructor
A new instance of NewParams.
Constructor Details
#initialize(command) ⇒ NewParams
Returns a new instance of NewParams.
4 5 6 |
# File 'lib/hammer_cli_foreman/option_sources/new_params.rb', line 4 def initialize(command) @command = command end |
Instance Method Details
#get_options(_defined_options, result) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/hammer_cli_foreman/option_sources/new_params.rb', line 8 def (, result) resource_names = @command.class.option_builder.builders .select { |b| b.class == HammerCLIForeman::UpdateDependentSearchablesOptionBuilder } .collect(&:resource) .collect(&:singular_name) new_result = resource_names.each_with_object({}) do |name, results| new_name = @command.send("option_new_#{name}_name") || @command.send("option_new_#{name}_title") results["option_new_#{name}_id"] = if new_name @command.resolver.send("#{name}_id", 'option_name' => new_name) else @command.send("option_new_#{name}_id") end end result.merge!(new_result) end |