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-8.17.0 lib/rock_rms/transform_hash_keys.rb
rock_rms-8.16.0 lib/rock_rms/transform_hash_keys.rb
rock_rms-8.15.2 lib/rock_rms/transform_hash_keys.rb
rock_rms-8.15.1 lib/rock_rms/transform_hash_keys.rb
rock_rms-8.15.0 lib/rock_rms/transform_hash_keys.rb
rock_rms-8.14.0 lib/rock_rms/transform_hash_keys.rb
rock_rms-8.13.0 lib/rock_rms/transform_hash_keys.rb
rock_rms-8.12.0 lib/rock_rms/transform_hash_keys.rb
rock_rms-8.11.0 lib/rock_rms/transform_hash_keys.rb
rock_rms-8.10.0 lib/rock_rms/transform_hash_keys.rb
rock_rms-8.9.0 lib/rock_rms/transform_hash_keys.rb
rock_rms-8.8.0 lib/rock_rms/transform_hash_keys.rb
rock_rms-8.7.0 lib/rock_rms/transform_hash_keys.rb
rock_rms-8.6.0 lib/rock_rms/transform_hash_keys.rb