Class: AbstractMapper
- Inherits:
-
Object
- Object
- AbstractMapper
- Extended by:
- DSL
- Defined in:
- lib/abstract_mapper.rb,
lib/abstract_mapper/dsl.rb,
lib/abstract_mapper/node.rb,
lib/abstract_mapper/rule.rb,
lib/abstract_mapper/rules.rb,
lib/abstract_mapper/branch.rb,
lib/abstract_mapper/builder.rb,
lib/abstract_mapper/command.rb,
lib/abstract_mapper/commands.rb,
lib/abstract_mapper/settings.rb,
lib/abstract_mapper/functions.rb,
lib/abstract_mapper/optimizer.rb,
lib/abstract_mapper/pair_rule.rb,
lib/abstract_mapper/sole_rule.rb,
lib/abstract_mapper/attributes.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: Attributes, DSL, Errors, Functions Classes: Branch, Builder, Command, Commands, Node, Optimizer, PairRule, Rule, Rules, Settings, SoleRule
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.
59 60 61 |
# File 'lib/abstract_mapper.rb', line 59 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]
81 82 83 |
# File 'lib/abstract_mapper.rb', line 81 def call(input) @transproc.call(input) end |
.initialize ⇒ Object
68 69 70 71 72 |
# File 'lib/abstract_mapper.rb', line 68 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 61
|