Class: AbstractMapper::Builder Private

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

Builds the immutable abstract syntax tree (AST) using DSL commands.

Examples:

Builder.update do
  field :user do     # DSL method
    add_prefix :user # DSL method for subtree
  end
end
# => <Root() [<Field(:user) [<AddPrefix(:user)>]>]>

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.commandsAbstractMapper::Commands

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 DSL commands.

Returns:



25
# File 'lib/abstract_mapper/builder.rb', line 25

attr_writer :commands

Instance Attribute Details

#treeAbstractMapper::Branch (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 updated tree.

Returns:



50
51
52
# File 'lib/abstract_mapper/builder.rb', line 50

def tree
  @tree
end

Class Method Details

.initialize(node, &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.



64
65
66
67
68
69
# File 'lib/abstract_mapper/builder.rb', line 64

def initialize(node, &block)
  @tree     = node
  @commands = self.class.commands
  instance_eval(&block) if block_given?
  IceNine.deep_freeze(self)
end

.new(node, &block) ⇒ AbstractMapper::Builder

Builds the AST by recursively adding new nodes, using the commands

Parameters:

  • node (AbstractMapper::Branch)

    The root of the tree to be updated

  • block (Proc)

    The block with DSL commands for adding subnodes

Returns:



# File 'lib/abstract_mapper/builder.rb', line 52