Module: ForemanMaintain::Cli::TransformClampOptions::ParamsToOptions
- Defined in:
- lib/foreman_maintain/cli/transform_clamp_options.rb
Instance Method Summary collapse
- #option_switches(param) ⇒ Object
- #option_type(param) ⇒ Object
- #param_to_option(param, custom = {}) ⇒ Object
- #params_to_options(params) ⇒ Object
Instance Method Details
#option_switches(param) ⇒ Object
57 58 59 |
# File 'lib/foreman_maintain/cli/transform_clamp_options.rb', line 57 def option_switches(param) ['--' + dashize(param.name.to_s)] end |
#option_type(param) ⇒ Object
61 62 63 |
# File 'lib/foreman_maintain/cli/transform_clamp_options.rb', line 61 def option_type(param) param.flag? ? :flag : param.name.to_s.upcase end |
#param_to_option(param, custom = {}) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/foreman_maintain/cli/transform_clamp_options.rb', line 45 def param_to_option(param, custom = {}) switches = custom.fetch(:switches, option_switches(param)) opt_type = custom.fetch(:type, option_type(param)) description = custom.fetch(:description, param.description) = custom.fetch(:options, {}) # clamp doesnt allow required flags [:required] ||= param.required? unless param.flag? [:multivalued] ||= param.array? option(switches, opt_type, description, ) end |
#params_to_options(params) ⇒ Object
39 40 41 42 43 |
# File 'lib/foreman_maintain/cli/transform_clamp_options.rb', line 39 def (params) params.each_value do |param| param_to_option(param) end end |