Module: Openra::Struct::Functions
- Extended by:
- Dry::Transformer::Registry
- Defined in:
- lib/openra/struct/functions.rb
Class Method Summary collapse
Class Method Details
.deep_stringify_keys(hash) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/openra/struct/functions.rb', line 18 def self.deep_stringify_keys(hash) hash.each_with_object({}) do |(key, value), output| output[key.to_s] = case value when Hash deep_stringify_keys(value) when Array value.map { |item| item.is_a?(Hash) ? deep_stringify_keys(item) : item } else value end end end |
.sequence(hash, prefix, into) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/openra/struct/functions.rb', line 10 def self.sequence(hash, prefix, into) keys = hash.keys.select { |key| key.start_with?(prefix + '@') } hash[into] = keys.map { |key| hash[key] } hash end |