Class: AbstractMapper::Rules Private

Inherits:
Object
  • Object
show all
Defined in:
lib/abstract_mapper/rules.rb,
lib/abstract_mapper/rules/base.rb,
lib/abstract_mapper/rules/pair.rb,
lib/abstract_mapper/rules/sole.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 rules applicable to nodes of AST

API:

  • private

Defined Under Namespace

Classes: Base, Pair, Sole

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#registryArray<AbstractMapper::Rules::Base> (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 list of rules applicable to AST.

Returns:

  • the list of rules applicable to AST

API:

  • private



20
21
22
# File 'lib/abstract_mapper/rules.rb', line 20

def registry
  @registry
end

Class Method Details

.<<(other) ⇒ 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.

Returns the copy of current registry with the new rule added

Parameters:

API:

  • private



43
44
45
# File 'lib/abstract_mapper/rules.rb', line 43

def <<(other)
  self.class.new(registry + [other])
end

.[](nodes) ⇒ Array<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.

Applies all the registered rules to the array of nodes

Parameters:

Returns:

  • The optimized array of nodes

API:

  • private



53
54
55
# File 'lib/abstract_mapper/rules.rb', line 53

def [](nodes)
  @transproc ? @transproc[nodes] : nodes
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.

API:

  • private



31
32
33
34
35
# File 'lib/abstract_mapper/rules.rb', line 31

def initialize(registry = [])
  @registry  = registry.dup
  @transproc = registry.map(&:transproc).inject(:>>)
  IceNine.deep_freeze(self)
end

.new(registry) ⇒ AbstractMapper::Rules

Creates a registry with array of rules

Parameters:

  • Array of rules

Returns:



# File 'lib/abstract_mapper/rules.rb', line 22