class DataMaps::Converter::Map

Map values

@since 0.0.1

Public Instance Methods

after_initialize() click to toggle source

The after initialize callback

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

The execute method to convert the given data

@param [mixed] data

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