Class: AbstractMapper::Commands::Base Private

Inherits:
Object
  • Object
show all
Defined in:
lib/abstract_mapper/commands/base.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

Method #call builds a correspodning node for the AST.

API:

  • private

Instance Attribute Summary collapse

Class Method Summary collapse

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.

Returns:

  • The converter of the command’s arguments into the node’s

API:

  • private



31
32
33
# File 'lib/abstract_mapper/commands/base.rb', line 31

def converter
  @converter
end

#klassClass (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.

Returns:

  • The class of the node to be created

API:

  • private



25
26
27
# File 'lib/abstract_mapper/commands/base.rb', line 25

def klass
  @klass
end

#nameSymbol (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.

Returns:

  • The name of the DSL command

API:

  • private



19
20
21
# File 'lib/abstract_mapper/commands/base.rb', line 19

def name
  @name
end

Class Method Details

.call(*args, &block) ⇒ AbstractMapper::AST::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

Parameters:

  • The argument of the command

Returns:

API:

  • private



60
61
62
63
# File 'lib/abstract_mapper/commands/base.rb', line 60

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.

API:

  • private



44
45
46
47
48
49
50
# 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

.new(name, klass, converter) ⇒ AbstractMapper::Commands::Base

Creates the named command for node klass and arguments converter

Parameters:

  • The name of the DSL command

  • The klass of the node to be created

  • The function that coerces attributes

Returns:



# File 'lib/abstract_mapper/commands/base.rb', line 33