Class: AbstractMapper::Rules Private

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

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

Returns:



15
16
17
# File 'lib/abstract_mapper/rules.rb', line 15

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:



38
39
40
# File 'lib/abstract_mapper/rules.rb', line 38

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

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



48
49
50
# File 'lib/abstract_mapper/rules.rb', line 48

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.



26
27
28
29
30
# File 'lib/abstract_mapper/rules.rb', line 26

def initialize(registry = [])
  @registry  = registry.dup.freeze
  @transproc = ordered.map(&:transproc).inject(:>>)
  freeze
end

.new(registry) ⇒ AbstractMapper::Rules

Creates a registry with array of rules

Parameters:

Returns:



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