Class: DeepHashTransformer

Inherits:
Object
  • Object
show all
Defined in:
lib/deep_hash_transformer.rb,
lib/deep_hash_transformer/version.rb

Constant Summary collapse

OPS =
{
  dasherize: ->(val) { val.to_s.tr('_', '-') },
  identity: ->(val) { val },
  stringify: ->(val) { val.to_s },
  symbolize: ->(val) { val.to_sym },
  underscore: ->(val) { val.to_s.tr('-', '_') }
}.freeze
VERSION =
'2.0.0'

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ DeepHashTransformer

Returns a new instance of DeepHashTransformer.



14
15
16
# File 'lib/deep_hash_transformer.rb', line 14

def initialize(hash)
  @hash = hash
end

Instance Method Details

#tr(*ops) ⇒ Object



18
19
20
# File 'lib/deep_hash_transformer.rb', line 18

def tr(*ops)
  transform_value(hash, ops)
end