Class: Pacer::RouteBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/pacer/route_builder.rb

Constant Summary collapse

REJECT_KEYS =
Set[:element_type, :wrapper, :extensions, :modules, :graph,
:back, :filter, :side_effect, :transform, :visitor,
:based_on]

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRouteBuilder

Returns a new instance of RouteBuilder.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/pacer/route_builder.rb', line 17

def initialize
  @types = Hash.new do |h, type_def|
    h[type_def] = Class.new(Route) do
      type_def.each do |mods|
        mods.each do |mod|
          include mod
        end
      end
    end
  end

  @element_types = Hash.new { |h, k| h[k] = [] }
  element_types[:vertex] = [Pacer::Core::Graph::ElementRoute, Pacer::Core::Graph::VerticesRoute]
  element_types[:edge] = [Pacer::Core::Graph::ElementRoute, Pacer::Core::Graph::EdgesRoute]
  element_types[:mixed] = [Pacer::Core::Graph::ElementRoute, Pacer::Core::Graph::MixedRoute]
  element_types[:path] = [Pacer::Core::ArrayRoute, Pacer::Core::Graph::PathRoute]
  element_types[:string] = [Pacer::Core::StringRoute]
  element_types[:array] = [Pacer::Core::ArrayRoute]
  element_types[:hash] = [Pacer::Core::HashRoute]
end

Class Attribute Details

.currentObject



10
11
12
# File 'lib/pacer/route_builder.rb', line 10

def current
  @current ||= RouteBuilder.new
end

Instance Attribute Details

#element_typesObject (readonly)

Returns the value of attribute element_types.



15
16
17
# File 'lib/pacer/route_builder.rb', line 15

def element_types
  @element_types
end

#typesObject (readonly)

Returns the value of attribute types.



15
16
17
# File 'lib/pacer/route_builder.rb', line 15

def types
  @types
end

Instance Method Details

#chain(source, args) ⇒ Object



38
39
40
# File 'lib/pacer/route_builder.rb', line 38

def chain(source, args)
  types[type_def(source, args)].new source, configuration(source, args), arguments(source, args)
end