Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/beyond_api/ext.rb
Instance Method Summary collapse
Instance Method Details
#camelize_keys ⇒ Object
19 20 21 |
# File 'lib/beyond_api/ext.rb', line 19 def camelize_keys deep_transform_keys { |key| key.to_s.camelize(false) } end |
#deep_transform_keys(&block) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/beyond_api/ext.rb', line 4 def deep_transform_keys(&block) result = {} each do |key, value| result[yield(key)] = case value when Hash value.deep_transform_keys(&block) when Array value.camelize_keys else value end end result end |
#underscorize_keys ⇒ Object
23 24 25 |
# File 'lib/beyond_api/ext.rb', line 23 def underscorize_keys deep_transform_keys { |key| key.to_s.underscore } end |