Class: AbstractMapper::Commands Private
- Inherits:
-
Object
- Object
- AbstractMapper::Commands
- Defined in:
- lib/abstract_mapper/commands.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.
Registry of DSL commands used by the builder
Instance Attribute Summary collapse
-
#registry ⇒ Hash<Symbol => Class>
readonly
private
The registry of command names, pointing to types of the nodes, that should be built for adding to AST.
Class Method Summary collapse
-
.<<(other) ⇒ undefined
private
Returns a new immutable registry with added command name and type.
-
.[](name, *args, &block) ⇒ Object
private
Builds a node by the name of DSL command.
- .initialize(registry = {}) ⇒ Object private
-
.new(registry = {}) ⇒ Faceter::Commands
Creates an immutable collection of commands.
Instance Attribute Details
#registry ⇒ Hash<Symbol => 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 registry of command names, pointing to types of the nodes, that should be built for adding to AST.
17 18 19 |
# File 'lib/abstract_mapper/commands.rb', line 17 def registry @registry end |
Class Method Details
.<<(other) ⇒ undefined
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 a new immutable registry with added command name and type
39 40 41 42 43 |
# File 'lib/abstract_mapper/commands.rb', line 39 def <<(other) name = other[0] node = other[1] self.class.new registry.merge(name.to_sym => node) end |
.[](name, *args, &block) ⇒ 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.
Builds a node by the name of DSL command
Skips the block if a registered node is a branch
57 58 59 60 61 |
# File 'lib/abstract_mapper/commands.rb', line 57 def [](name, *args, &block) type = get(name) branch = Functions[:subclass?, Branch][type] branch ? type.new(*args) : type.new(*args, &block) end |
.initialize(registry = {}) ⇒ 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.
28 29 30 31 |
# File 'lib/abstract_mapper/commands.rb', line 28 def initialize(registry = {}) @registry = registry.dup.freeze freeze end |
.new(registry = {}) ⇒ Faceter::Commands
Creates an immutable collection of commands
|
|
# File 'lib/abstract_mapper/commands.rb', line 19
|