Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/backlog_kit/hash_extensions.rb

Instance Method Summary collapse

Instance Method Details

#camelize_keys!Hash

Camelize all keys of the hash

Returns:

  • (Hash)

    The hash with camelized keys



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/backlog_kit/hash_extensions.rb', line 7

def camelize_keys!
  deep_transform_keys! do |key|
    key.to_s
      .split(/(_*\d+_*)/)
      .reject(&:empty?)
      .map { |k| k.camelize(:lower) }
      .join('_')
      .to_sym
  end

  self
end