Sha256: 31a39fbda44e31b5a3b0311d73110142aa3b78858d611473deb56c797b3bd4b2

Contents?: true

Size: 369 Bytes

Versions: 7

Compression:

Stored size: 369 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 { |k| k.camelize(:lower) }
        .join('_')
        .to_sym
    end

    self
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
backlog_kit-0.19.0 lib/backlog_kit/hash_extensions.rb
backlog_kit-0.18.0 lib/backlog_kit/hash_extensions.rb
backlog_kit-0.17.0 lib/backlog_kit/hash_extensions.rb
backlog_kit-0.16.0 lib/backlog_kit/hash_extensions.rb
resas_kit-0.1.0 lib/resas_kit/hash_extensions.rb
backlog_kit-0.15.0 lib/backlog_kit/hash_extensions.rb
backlog_kit-0.14.0 lib/backlog_kit/hash_extensions.rb