Module: Darthjee::CoreExt::Hash::Cameliazable
- Included in:
- Darthjee::CoreExt::Hash
- Defined in:
- lib/darthjee/core_ext/hash/cameliazable.rb
Overview
Module holding methods for camelizing keys of a hash
Instance Method Summary collapse
-
#camelize_keys ⇒ ::Hash
Change keys to CamelCase without changing the original hash.
-
#camelize_keys! ⇒ ::Hash
Change keys to CamelCase changing the original hash.
-
#lower_camelize_keys ⇒ ::Hash
Camelize all keys in the hash as `key.camelize(:lower).
-
#lower_camelize_keys!(**options) ⇒ ::Hash
Camelize all keys in the hash.
-
#underscore_keys ⇒ ::Hash
Change all keys to be snakecase.
-
#underscore_keys! ⇒ ::Hash
Change all keys to be snakecase.
Instance Method Details
#camelize_keys ⇒ ::Hash
Change keys to CamelCase without changing the original hash
35 36 37 |
# File 'lib/darthjee/core_ext/hash/cameliazable.rb', line 35 def camelize_keys(**) dup.camelize_keys!(**) end |
#camelize_keys! ⇒ ::Hash
Change keys to CamelCase changing the original hash
50 51 52 |
# File 'lib/darthjee/core_ext/hash/cameliazable.rb', line 50 def camelize_keys!(**) Hash::KeyChanger.new(self).camelize_keys(**) end |
#lower_camelize_keys ⇒ ::Hash
Camelize all keys in the hash as `key.camelize(:lower)
65 66 67 |
# File 'lib/darthjee/core_ext/hash/cameliazable.rb', line 65 def lower_camelize_keys(**) dup.lower_camelize_keys!(**) end |
#lower_camelize_keys!(**options) ⇒ ::Hash
Camelize all keys in the hash
74 75 76 77 78 |
# File 'lib/darthjee/core_ext/hash/cameliazable.rb', line 74 def lower_camelize_keys!(**) = .merge(uppercase_first_letter: false) camelize_keys!(**) end |
#underscore_keys ⇒ ::Hash
Change all keys to be snakecase
THis method does not change the original hash
99 100 101 |
# File 'lib/darthjee/core_ext/hash/cameliazable.rb', line 99 def underscore_keys(**) dup.underscore_keys!(**) end |
#underscore_keys! ⇒ ::Hash
Change all keys to be snakecase
THis method changes the original hash
116 117 118 |
# File 'lib/darthjee/core_ext/hash/cameliazable.rb', line 116 def underscore_keys!(**) Hash::KeyChanger.new(self).underscore_keys(**) end |