class AbstractMapper

The configurable base class for mappers

The mapper DSL is configured by assigning it a specific settings:

class BaseMapper < AbstractMapper::Mapper
  configure do
    command :list, List     # domain-specific command
    command :rename, Rename # domain-specific command

    rule MergeLists         # domain-specific rule
  end
end

Then a configured mapper can use a corresponding DSL commands

class ConcreteMapper < BaseMapper
  list do
    rename :foo, to: :bar
  end
end

@api public

Constants

VERSION

The semantic version of the module. @see semver.org/ Semantic versioning 2.0

Attributes

tree[R]

@!attribute [r] tree

@return [AbstractMapper::Branch] AST

Public Class Methods

new() click to toggle source

@private

# File lib/abstract_mapper.rb, line 57
def initialize
  @tree = self.class.finalize
  @transproc = @tree.transproc
  IceNine.deep_freeze(self)
end

Public Instance Methods

call(input) click to toggle source

Maps the input data to some output using the transformation, described by the optimized [#tree]

@param [Object] input

@return [Object]

# File lib/abstract_mapper.rb, line 70
def call(input)
  @transproc.call(input)
end
method_missing(name, *args, &block) click to toggle source
# File lib/abstract_mapper/dsl.rb, line 56
def method_missing(name, *args, &block)
  @tree = settings.builder.update(tree) { public_send(name, *args, &block) }
end
respond_to_missing?(*) click to toggle source
# File lib/abstract_mapper/builder.rb, line 78
def respond_to_missing?(*)
  true
end
update(node, &block) click to toggle source
# File lib/abstract_mapper/builder.rb, line 82
def update(node, &block)
  self.class.update(node, &block)
end