class DataMaps::Converter::Key

Converts hash keys

@since 0.0.1

Public Instance Methods

after_initialize() click to toggle source

The after initialize callback

# File lib/data_maps/converter/key.rb, line 8
def after_initialize
  @option = option.with_indifferent_access
end
execute(data) click to toggle source

The execute method to convert the keys of given data

@param [mixed] data

# File lib/data_maps/converter/key.rb, line 15
def execute(data)
  case data
    when Hash then Hash[data.map{ |k,v| [option[k] || k, v] }]
    else data
  end
end