Module: Darthjee::CoreExt::Hash::Cameliazable
- Included in:
- Darthjee::CoreExt::Hash
- Defined in:
- lib/darthjee/core_ext/hash/cameliazable.rb
Overview
Module holding methods responsible for camelizing keys of a hash
Instance Method Summary collapse
-
#camelize_keys(options = {}) ⇒ ::Hash
Change keys to CamelCase without changing the original hash.
-
#camelize_keys!(options = {}) ⇒ ::Hash
Change keys to CamelCase changing the original hash.
-
#lower_camelize_keys(options = {}) ⇒ ::Hash
Camelize all keys in the hash as ‘key.camelize(:lower).
-
#lower_camelize_keys!(options = {}) ⇒ ::Hash
Camelize all keys in the hash.
- #underscore_keys(options = {}) ⇒ Object
- #underscore_keys!(options = {}) ⇒ Object
Instance Method Details
#camelize_keys(options = {}) ⇒ ::Hash
Change keys to CamelCase without changing the original hash
36 37 38 |
# File 'lib/darthjee/core_ext/hash/cameliazable.rb', line 36 def camelize_keys( = {}) dup.camelize_keys!() end |
#camelize_keys!(options = {}) ⇒ ::Hash
Change keys to CamelCase changing the original hash
51 52 53 |
# File 'lib/darthjee/core_ext/hash/cameliazable.rb', line 51 def camelize_keys!( = {}) Hash::KeyChanger.new(self).camelize_keys() end |
#lower_camelize_keys(options = {}) ⇒ ::Hash
Camelize all keys in the hash as ‘key.camelize(:lower)
66 67 68 |
# File 'lib/darthjee/core_ext/hash/cameliazable.rb', line 66 def lower_camelize_keys( = {}) dup.lower_camelize_keys!() end |
#lower_camelize_keys!(options = {}) ⇒ ::Hash
Camelize all keys in the hash
75 76 77 78 79 |
# File 'lib/darthjee/core_ext/hash/cameliazable.rb', line 75 def lower_camelize_keys!( = {}) = .merge(uppercase_first_letter: false) camelize_keys!() end |
#underscore_keys(options = {}) ⇒ Object
81 82 83 |
# File 'lib/darthjee/core_ext/hash/cameliazable.rb', line 81 def underscore_keys( = {}) dup.underscore_keys!() end |
#underscore_keys!(options = {}) ⇒ Object
85 86 87 |
# File 'lib/darthjee/core_ext/hash/cameliazable.rb', line 85 def underscore_keys!( = {}) Hash::KeyChanger.new(self).underscore_keys() end |