Class: AbstractMapper::Command Private
- Inherits:
-
Object
- Object
- AbstractMapper::Command
- Defined in:
- lib/abstract_mapper/command.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Describes the command of the mapper
Every command has a name, a node that is added to the AST and the function, that converts command attributes into the node’s.
Method ‘#call` builds a correspodning node for the AST.
Instance Attribute Summary collapse
-
#converter ⇒ #call
readonly
private
The converter of the command’s arguments into the node’s.
-
#klass ⇒ Class
readonly
private
The class of the node to be created.
-
#name ⇒ Symbol
readonly
private
The name of the DSL command.
Class Method Summary collapse
-
.call(*args, &block) ⇒ AbstractMapper::Node
private
Builds the AST node.
- .initialize(name, klass, converter = nil) ⇒ Object private
-
.new(name, klass, converter) ⇒ AbstractMapper::Command
Creates the named command for node klass and arguments converter.
Instance Attribute Details
#converter ⇒ #call (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns The converter of the command’s arguments into the node’s.
32 33 34 |
# File 'lib/abstract_mapper/command.rb', line 32 def converter @converter end |
#klass ⇒ Class (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns The class of the node to be created.
26 27 28 |
# File 'lib/abstract_mapper/command.rb', line 26 def klass @klass end |
#name ⇒ Symbol (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns The name of the DSL command.
20 21 22 |
# File 'lib/abstract_mapper/command.rb', line 20 def name @name end |
Class Method Details
.call(*args, &block) ⇒ AbstractMapper::Node
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Builds the AST node
61 62 63 64 |
# File 'lib/abstract_mapper/command.rb', line 61 def call(*args, &block) block = nil if @branch klass.new(converter.call(*args), &block) end |
.initialize(name, klass, converter = nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
45 46 47 48 49 50 51 |
# File 'lib/abstract_mapper/command.rb', line 45 def initialize(name, klass, converter = nil) @name = name.to_sym @klass = klass @branch = Functions[:subclass?, Branch][klass] @converter = converter || proc { |args = {}| args } IceNine.deep_freeze(self) end |
.new(name, klass, converter) ⇒ AbstractMapper::Command
Creates the named command for node klass and arguments converter
|
# File 'lib/abstract_mapper/command.rb', line 34
|