Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/fullcontact/ext/hash/to_snake_keys.rb
Overview
Hash.to_snake_keys
Instance Method Summary collapse
-
#to_snake_keys(value = self) ⇒ Object
Recursively converts CamelCase and camelBack JSON-style hash keys to Rubyish snake_case, suitable for use during instantiation of Ruby model attributes.
Instance Method Details
#to_snake_keys(value = self) ⇒ Object
Recursively converts CamelCase and camelBack JSON-style hash keys to Rubyish snake_case, suitable for use during instantiation of Ruby model attributes.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/fullcontact/ext/hash/to_snake_keys.rb', line 7 def to_snake_keys(value = self) case value when Array value.map { |v| to_snake_keys(v) } when Hash snake_hash(value) else value end end |