Class: ForemanDeployments::Config::Hash
- Inherits:
-
ActiveSupport::HashWithIndifferentAccess
- Object
- ActiveSupport::HashWithIndifferentAccess
- ForemanDeployments::Config::Hash
- Defined in:
- app/lib/foreman_deployments/config/hash.rb
Instance Method Summary collapse
- #configuration ⇒ Object
- #configure(values) ⇒ Object
- #configured ⇒ Object
- #merge_configuration(values) ⇒ Object
- #transform!(&block) ⇒ Object
Instance Method Details
#configuration ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'app/lib/foreman_deployments/config/hash.rb', line 29 def configuration result = configuration_storage.deep_clone each do |key, value| if value.respond_to?(:configuration) result[key.to_s] = value.configuration unless value.configuration.nil? end end result.empty? ? nil : result end |
#configure(values) ⇒ Object
10 11 12 13 14 15 |
# File 'app/lib/foreman_deployments/config/hash.rb', line 10 def configure(values) configuration_storage.clear values.each do |key, value| configure_key(key, value, :configure) end end |
#configured ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/lib/foreman_deployments/config/hash.rb', line 17 def configured result = configuration_storage.deep_clone each do |key, item| if item.respond_to?(:configured) result[key.to_s] = item.configured else result[key.to_s] = item end end result end |
#merge_configuration(values) ⇒ Object
4 5 6 7 8 |
# File 'app/lib/foreman_deployments/config/hash.rb', line 4 def merge_configuration(values) values.each do |key, value| configure_key(key, value, :merge_configuration) end end |
#transform!(&block) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'app/lib/foreman_deployments/config/hash.rb', line 39 def transform!(&block) keys.each do |key| new_key, new_value = block.call(key, self[key]) self[key] = new_value self[new_key] = delete(key) if new_key != key end self end |