Class: HammerCLIForeman::IdResolver
- Inherits:
-
Object
- Object
- HammerCLIForeman::IdResolver
- Defined in:
- lib/hammer_cli_foreman/id_resolver.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
Instance Method Summary collapse
-
#initialize(api, searchables) ⇒ IdResolver
constructor
A new instance of IdResolver.
- #scoped_options(scope, options) ⇒ Object
Constructor Details
#initialize(api, searchables) ⇒ IdResolver
Returns a new instance of IdResolver.
71 72 73 74 75 |
# File 'lib/hammer_cli_foreman/id_resolver.rb', line 71 def initialize(api, searchables) @api = api @searchables = searchables define_id_finders end |
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
69 70 71 |
# File 'lib/hammer_cli_foreman/id_resolver.rb', line 69 def api @api end |
Instance Method Details
#scoped_options(scope, options) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/hammer_cli_foreman/id_resolver.rb', line 77 def (scope, ) = .dup resource = HammerCLIForeman.param_to_resource(scope) return unless resource option_names = searchables(resource).map { |s| s.name } option_names << "id" option_names.each do |name| option = HammerCLI.option_accessor_name(name) scoped_option = HammerCLI.option_accessor_name("#{scope}_#{name}") # remove the scope # e.g. option_architecture_id -> option_id if [scoped_option] [option] = .delete(scoped_option) else .delete(option) end end end |