Class: DataMaps::Mapper

Inherits:
Object
  • Object
show all
Defined in:
lib/data_maps/mapper.rb

Overview

The base mapper class which handles all mapping logic

Since:

  • 0.0.1

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mapping) ⇒ Mapper

Initializer for the Mapper class

Parameters:

  • mapping (Mapping)

    the mapping which will used to map data

Raises:

  • (ArgumentError)

    when mapping is not a correct mapping object

Since:

  • 0.0.1



14
15
16
17
18
# File 'lib/data_maps/mapper.rb', line 14

def initialize(mapping)
  raise ArgumentError.new('The mapping should be a DataMaps::Mapping::Base') unless mapping.is_a? DataMaps::Mapping

  @mapping = mapping
end

Instance Attribute Details

#mappingObject

Attribute Accessors

Since:

  • 0.0.1



6
7
8
# File 'lib/data_maps/mapper.rb', line 6

def mapping
  @mapping
end

Instance Method Details

#convert(data) ⇒ Object

Execute

Since:

  • 0.0.1



21
22
23
# File 'lib/data_maps/mapper.rb', line 21

def convert(data)
  mapping.execute(data.stringify_keys)
end