Class: ForemanDeployments::Config::Array
- Inherits:
-
Array
- Object
- Array
- ForemanDeployments::Config::Array
- Defined in:
- app/lib/foreman_deployments/config/array.rb
Instance Method Summary collapse
- #configuration ⇒ Object
- #configure(values) ⇒ Object
- #configured ⇒ Object
- #merge_configuration(values) ⇒ Object
- #transform!(&block) ⇒ Object
Instance Method Details
#configuration ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'app/lib/foreman_deployments/config/array.rb', line 31 def configuration result = configuration_storage.deep_clone each_with_index do |item, index| if item.respond_to?(:configuration) result[index] = item.configuration unless item.configuration.nil? end end result.empty? ? nil : result end |
#configure(values) ⇒ Object
11 12 13 14 15 16 17 |
# File 'app/lib/foreman_deployments/config/array.rb', line 11 def configure(values) values = ensure_hash(values) configuration_storage.clear values.map do |index, value| configure_index(index, value, :configure) end end |
#configured ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/lib/foreman_deployments/config/array.rb', line 19 def configured map.with_index do |item, index| if item.respond_to?(:configured) item.configured elsif item.nil? configuration_storage[index] else item end end end |
#merge_configuration(values) ⇒ Object
4 5 6 7 8 9 |
# File 'app/lib/foreman_deployments/config/array.rb', line 4 def merge_configuration(values) values = ensure_hash(values) values.map do |index, value| configure_index(index, value, :merge_configuration) end end |
#transform!(&block) ⇒ Object
41 42 43 44 45 46 |
# File 'app/lib/foreman_deployments/config/array.rb', line 41 def transform!(&block) self.map! do |item| block.call(item) end self end |