Class: AbstractMapper
- Inherits:
-
Object
- Object
- AbstractMapper
- Extended by:
- DSL
- Defined in:
- lib/abstract_mapper.rb,
lib/abstract_mapper/ast.rb,
lib/abstract_mapper/dsl.rb,
lib/abstract_mapper/rules.rb,
lib/abstract_mapper/errors.rb,
lib/abstract_mapper/builder.rb,
lib/abstract_mapper/ast/node.rb,
lib/abstract_mapper/commands.rb,
lib/abstract_mapper/settings.rb,
lib/abstract_mapper/functions.rb,
lib/abstract_mapper/optimizer.rb,
lib/abstract_mapper/ast/branch.rb,
lib/abstract_mapper/rules/base.rb,
lib/abstract_mapper/rules/pair.rb,
lib/abstract_mapper/rules/sole.rb,
lib/abstract_mapper/commands/base.rb,
lib/abstract_mapper/errors/wrong_node.rb,
lib/abstract_mapper/errors/wrong_rule.rb,
lib/abstract_mapper/errors/unknown_command.rb
Overview
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
Defined Under Namespace
Modules: AST, DSL, Errors, Functions Classes: Builder, Commands, Optimizer, Rules, Settings
Instance Attribute Summary collapse
-
#tree ⇒ AbstractMapper::Branch
readonly
AST.
Attributes included from DSL
Class Method Summary collapse
-
.call(input) ⇒ Object
Maps the input data to some output using the transformation, described by the optimized [#tree].
- .initialize ⇒ Object
-
.new ⇒ AbstractMapper::Mapper
Creates a mapper instance with the optimized AST.
Methods included from DSL
configure, finalize, inherited
Instance Attribute Details
#tree ⇒ AbstractMapper::Branch (readonly)
Returns AST.
48 49 50 |
# File 'lib/abstract_mapper.rb', line 48 def tree @tree end |
Class Method Details
.call(input) ⇒ Object
Maps the input data to some output using the transformation, described by the optimized [#tree]
70 71 72 |
# File 'lib/abstract_mapper.rb', line 70 def call(input) @transproc.call(input) end |
.initialize ⇒ Object
57 58 59 60 61 |
# File 'lib/abstract_mapper.rb', line 57 def initialize @tree = self.class.finalize @transproc = @tree.transproc IceNine.deep_freeze(self) end |
.new ⇒ AbstractMapper::Mapper
Creates a mapper instance with the optimized AST
|
# File 'lib/abstract_mapper.rb', line 50
|