Class: CapsuleCRM::HashHelper
- Inherits:
-
Object
- Object
- CapsuleCRM::HashHelper
- Defined in:
- lib/capsule_crm/hash_helper.rb
Class Method Summary collapse
- .camelize_keys(hash) ⇒ Object
- .camelize_keys!(hash) ⇒ Object
- .underscore_keys(hash) ⇒ Object
- .underscore_keys!(hash) ⇒ Object
Class Method Details
.camelize_keys(hash) ⇒ Object
22 23 24 25 |
# File 'lib/capsule_crm/hash_helper.rb', line 22 def self.camelize_keys(hash) camelize_keys!(hash) hash end |
.camelize_keys!(hash) ⇒ Object
16 17 18 19 20 |
# File 'lib/capsule_crm/hash_helper.rb', line 16 def self.camelize_keys!(hash) hash.keys.each do |key| hash[key.to_s.camelize(:lower)] = hash.delete(key) end end |
.underscore_keys(hash) ⇒ Object
11 12 13 14 |
# File 'lib/capsule_crm/hash_helper.rb', line 11 def self.underscore_keys(hash) underscore_keys!(hash) hash end |
.underscore_keys!(hash) ⇒ Object
5 6 7 8 9 |
# File 'lib/capsule_crm/hash_helper.rb', line 5 def self.underscore_keys!(hash) hash.keys.each do |key| hash[key.to_s.underscore] = hash.delete(key) end end |