Module: ForemanOpenscap::LookupKeyOverridesCommon
- Extended by:
- ActiveSupport::Concern
- Included in:
- LookupKeyOverrider
- Defined in:
- app/services/foreman_openscap/lookup_key_overrides_common.rb
Instance Method Summary collapse
- #missing_lookup_keys(hash) ⇒ Object
- #override(config) ⇒ Object
- #override_param(handler, param_name, param, config, key_type, default_value = nil) ⇒ Object
- #override_params(lookup_keys, config) ⇒ Object
- #override_policies_param(parameter, config) ⇒ Object
- #override_port_param(param, config) ⇒ Object
- #override_required_params(config) ⇒ Object
- #override_server_param(param, config) ⇒ Object
Instance Method Details
#missing_lookup_keys(hash) ⇒ Object
55 56 57 58 59 60 61 |
# File 'app/services/foreman_openscap/lookup_key_overrides_common.rb', line 55 def missing_lookup_keys(hash) return [] if hash.values.all? hash.reduce([]) do |memo, (key, value)| memo << key if value.blank? memo end end |
#override(config) ⇒ Object
5 6 7 8 |
# File 'app/services/foreman_openscap/lookup_key_overrides_common.rb', line 5 def override(config) return unless handle_config_not_available(config) override_required_params config end |
#override_param(handler, param_name, param, config, key_type, default_value = nil) ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'app/services/foreman_openscap/lookup_key_overrides_common.rb', line 46 def override_param(handler, param_name, param, config, key_type, default_value = nil) param.override = true param.hidden_value = false param.key_type = key_type param.default_value = default_value send("handle_#{handler}_param_override", config, param) end |
#override_params(lookup_keys, config) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/services/foreman_openscap/lookup_key_overrides_common.rb', line 18 def override_params(lookup_keys, config) policies_param = lookup_keys.find_by :key => config.policies_param port_param = lookup_keys.find_by :key => config.port_param server_param = lookup_keys.find_by :key => config.server_param missing_keys = missing_lookup_keys(config.policies_param => policies_param, config.port_param => port_param, config.server_param => server_param) return unless handle_missing_lookup_keys config, missing_keys.compact.join(', ') override_policies_param(policies_param, config) override_port_param(port_param, config) override_server_param(server_param, config) end |
#override_policies_param(parameter, config) ⇒ Object
34 35 36 |
# File 'app/services/foreman_openscap/lookup_key_overrides_common.rb', line 34 def override_policies_param(parameter, config) override_param 'policies', config.policies_param, parameter, config, 'array', config.policies_param_default_value end |
#override_port_param(param, config) ⇒ Object
38 39 40 |
# File 'app/services/foreman_openscap/lookup_key_overrides_common.rb', line 38 def override_port_param(param, config) override_param 'port', config.port_param, param, config, 'integer' end |
#override_required_params(config) ⇒ Object
10 11 12 13 14 15 16 |
# File 'app/services/foreman_openscap/lookup_key_overrides_common.rb', line 10 def override_required_params(config) return unless config.managed_overrides? item = config.find_config_item return unless handle_config_item_not_available(config, item) override_params item.public_send(config.override_method_name), config end |
#override_server_param(param, config) ⇒ Object
42 43 44 |
# File 'app/services/foreman_openscap/lookup_key_overrides_common.rb', line 42 def override_server_param(param, config) override_param 'server', config.server_param, param, config, 'string' end |