Sha256: 2f07594fcbceca9bddf50326ece94ea6cbfdddb0361a6adf53bd8e10b1995919

Contents?: true

Size: 374 Bytes

Versions: 1

Compression:

Stored size: 374 Bytes

Contents

require 'active_support/core_ext/hash/keys'

class Hash

  # Camelize all keys of the hash
  #
  # @return [Hash] The hash with camelized keys
  def camelize_keys!
    deep_transform_keys! do |key|
      key.to_s
        .split(/(_*\d+_*)/)
        .reject(&:empty?)
        .map { |key| key.camelize(:lower) }
        .join('_')
        .to_sym
    end

    self
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
backlog_kit-0.13.0 lib/backlog_kit/hash_extensions.rb