Module: ActiveSerialize::KeyFormatter

Defined in:
lib/active_serialize/key_formatter.rb

Class Method Summary collapse

Class Method Details

.call(config, hash) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/active_serialize/key_formatter.rb', line 5

def self.call(config, hash)
  return hash unless config.present?
  hash.deep_transform_keys! do |k, _|
    case config.to_sym
    when :underscore; k.underscore
    when :camelize; k.camelize
    when :camelize_lower; k.camelize(:lower)
    else k
    end
  end
end