Sha256: 35d20438a4ceeff37a31f2d5cb737c02b24b9d0149511292a54777b4f9383f49

Contents?: true

Size: 261 Bytes

Versions: 34

Compression:

Stored size: 261 Bytes

Contents

module TransformHashKeys
  def self.camelize_keys(hash)
    hash
      .filter { |_, v| v }
      .transform_keys { |k| camelize(k) }
  end

  def self.camelize(term)
    term.to_s.gsub(/(?:^|_+)([^_])/) { $1.upcase }.tap { |s| s[0] = s[0].downcase }
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
rock_rms-9.13.0 lib/rock_rms/transform_hash_keys.rb
rock_rms-9.12.0 lib/rock_rms/transform_hash_keys.rb
rock_rms-9.11.0 lib/rock_rms/transform_hash_keys.rb
rock_rms-9.10.0 lib/rock_rms/transform_hash_keys.rb
rock_rms-9.9.0 lib/rock_rms/transform_hash_keys.rb
rock_rms-9.8.0 lib/rock_rms/transform_hash_keys.rb
rock_rms-9.7.0 lib/rock_rms/transform_hash_keys.rb
rock_rms-9.6.0 lib/rock_rms/transform_hash_keys.rb
rock_rms-9.5.0 lib/rock_rms/transform_hash_keys.rb
rock_rms-9.4.0 lib/rock_rms/transform_hash_keys.rb
rock_rms-9.3.0 lib/rock_rms/transform_hash_keys.rb
rock_rms-9.2.0 lib/rock_rms/transform_hash_keys.rb
rock_rms-9.1.0 lib/rock_rms/transform_hash_keys.rb
rock_rms-9.0.0 lib/rock_rms/transform_hash_keys.rb
rock_rms-8.23.0 lib/rock_rms/transform_hash_keys.rb
rock_rms-8.22.0 lib/rock_rms/transform_hash_keys.rb
rock_rms-8.21.0 lib/rock_rms/transform_hash_keys.rb
rock_rms-8.20.0 lib/rock_rms/transform_hash_keys.rb
rock_rms-8.19.0 lib/rock_rms/transform_hash_keys.rb
rock_rms-8.18.0 lib/rock_rms/transform_hash_keys.rb