Module: Plissken::Methods
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.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/plissken/methods.rb', line 9 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 |