Module: Rudder::DSL::Util
Overview
Utility helper methods for DSL components.
This is ntended for internal use and is subject to change.
Instance Method Summary collapse
-
#_convert_h_val(value) ⇒ Object
Converts non-collections to YAML safe strings and collections to collections of YAML safe strings.
-
#_deep_to_h(hash) ⇒ Hash
Recursively converts keys and values of a Hash to YAML friendly values.
Instance Method Details
#_convert_h_val(value) ⇒ Object
Converts non-collections to YAML safe strings and collections to collections of YAML safe strings
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rudder/dsl/util.rb', line 30 def _convert_h_val(value) case value when Hash _deep_to_h(value) when Array value.map { |x| _convert_h_val(x) } when Symbol value.to_s else if value.respond_to? :to_h _deep_to_h(value.to_h) else value end end end |
#_deep_to_h(hash) ⇒ Hash
Recursively converts keys and values of a Hash to YAML friendly values
17 18 19 20 21 22 23 |
# File 'lib/rudder/dsl/util.rb', line 17 def _deep_to_h(hash) hash.map do |k, v| k = _convert_h_val(k) v = _convert_h_val(v) [k, v] end.to_h end |