class AbstractMapper::Commands::Base
Describes the command of the mapper
Method `#call` builds a correspodning node for the AST
.
@api private
Attributes
converter[R]
@!attribute [r] converter
@return [#call] The converter of the command's arguments into the node's
klass[R]
@!attribute [r] klass
@return [Class] The class of the node to be created
name[R]
@!attribute [r] name
@return [Symbol] The name of the DSL
command
Public Class Methods
new(name, klass, converter = nil)
click to toggle source
@private
# File lib/abstract_mapper/commands/base.rb, line 44 def initialize(name, klass, converter = nil) @name = name.to_sym @klass = klass @branch = Functions[:subclass?, AST::Branch][klass] @converter = converter || proc { |args = {}| args } IceNine.deep_freeze(self) end
Public Instance Methods
call(*args, &block)
click to toggle source
Builds the AST
node
@param [Object, Array] args
The argument of the command
@param [Proc] block
@return [AbstractMapper::AST::Node]
# File lib/abstract_mapper/commands/base.rb, line 60 def call(*args, &block) block = nil if @branch klass.new(converter.call(*args), &block) end