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.
- #puppetclass_ids(options) ⇒ Object
- #scoped_options(scope, options) ⇒ Object
Constructor Details
#initialize(api, searchables) ⇒ IdResolver
Returns a new instance of IdResolver.
79 80 81 82 83 |
# File 'lib/hammer_cli_foreman/id_resolver.rb', line 79 def initialize(api, searchables) @api = api @searchables = searchables define_id_finders end |
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
77 78 79 |
# File 'lib/hammer_cli_foreman/id_resolver.rb', line 77 def api @api end |
Instance Method Details
#puppetclass_ids(options) ⇒ Object
121 122 123 |
# File 'lib/hammer_cli_foreman/id_resolver.rb', line 121 def puppetclass_ids() [HammerCLI.option_accessor_name("ids")] || find_puppetclasses().collect { |c| c['id'] } end |
#scoped_options(scope, options) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/hammer_cli_foreman/id_resolver.rb', line 85 def (scope, ) = .dup resource = HammerCLIForeman.param_to_resource(scope) return unless resource option_names = searchables(resource).map { |s| s.name } option_names += searchables(resource).map { |s| s.plural_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 |