Class: HammerCLIForeman::Defaults
- Inherits:
-
HammerCLI::BaseDefaultsProvider
- Object
- HammerCLI::BaseDefaultsProvider
- HammerCLIForeman::Defaults
- Defined in:
- lib/hammer_cli_foreman/defaults.rb
Instance Method Summary collapse
- #get_defaults(param) ⇒ Object
-
#initialize(api_connection = HammerCLIForeman.foreman_api_connection) ⇒ Defaults
constructor
A new instance of Defaults.
Constructor Details
#initialize(api_connection = HammerCLIForeman.foreman_api_connection) ⇒ Defaults
Returns a new instance of Defaults.
4 5 6 7 8 9 |
# File 'lib/hammer_cli_foreman/defaults.rb', line 4 def initialize(api_connection = HammerCLIForeman.foreman_api_connection) @api_connection = api_connection @provider_name = 'foreman' @supported_defaults = [:organization_id, :location_id] @description = _('Use the default organization and/or location from the server') end |
Instance Method Details
#get_defaults(param) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/hammer_cli_foreman/defaults.rb', line 11 def get_defaults(param) param = "default_organization" if param == :organization_id param = "default_location" if param == :location_id user = get_user val = nil if user val = user["results"].first[param] if user["results"] val = val["id"] if val.is_a?(Hash) && param.include?("default") end val end |