Module: DataTranslation::Destination

Defined in:
lib/data_translation.rb

Overview

Provides helper methods for mapping and creating new objects from source data.

In addition to including the mixin DataTranslation::Destination, a class method called initialize_from_data_translation may optionally be provided that takes a hash of translated data. If not present, the from_source will pass a hash of the transformation results to the new method.

Multiple mappings may be given for a single destination by using different names for them. e.g. :source1 and :source2 as names yield different mappings.

Example Usage

class DestinationObject

include DataTranslation::Destination

def self.initialize_from_data_translation(results)
end

end

DestinationObject.data_translation_map(:source_name) do |dtm|

dtm.link 'first_key', 'Key1'

end

source = => ‘Value1’

new_object = DestinationObject.from_source(:source_name, source)

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object

Provides our class methods when included.



205
206
207
# File 'lib/data_translation.rb', line 205

def self.included(base)
  base.extend(ClassMethods)
end