Class: AppleCore::Transforms::Hash
- Inherits:
-
Object
- Object
- AppleCore::Transforms::Hash
- Defined in:
- lib/apple_core/transforms/hash.rb
Class Method Summary collapse
Class Method Details
.deep_underscore_keys(other) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/apple_core/transforms/hash.rb', line 10 def self.deep_underscore_keys(other) return other unless other.is_a? ::Hash other.each_with_object({}) do |(key, value), hash| value = case value when ::Hash deep_underscore_keys(value) when ::Array value.map do |item| deep_underscore_keys(item) end else value end hash[key.to_s.underscore] = value end end |