Class: Traver::GraphCreator

Inherits:
Object
  • Object
show all
Defined in:
lib/traver/graph_creator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(factory_name, params, factories_store, sequencer) ⇒ GraphCreator

Returns a new instance of GraphCreator.



6
7
8
9
10
11
12
13
14
15
# File 'lib/traver/graph_creator.rb', line 6

def initialize(factory_name, params, factories_store, sequencer)
  @factory_name    = factory_name
  @params          = params
  @factories_store = factories_store
  @sequencer       = sequencer
  
  @object_creator = ObjectCreator.new(factory_name, params, factories_store, sequencer)
  
  @graph = Graph.new
end

Instance Attribute Details

#factories_storeObject (readonly)

Returns the value of attribute factories_store.



3
4
5
# File 'lib/traver/graph_creator.rb', line 3

def factories_store
  @factories_store
end

#factory_nameObject (readonly)

Returns the value of attribute factory_name.



3
4
5
# File 'lib/traver/graph_creator.rb', line 3

def factory_name
  @factory_name
end

#graphObject (readonly)

Returns the value of attribute graph.



4
5
6
# File 'lib/traver/graph_creator.rb', line 4

def graph
  @graph
end

#paramsObject (readonly)

Returns the value of attribute params.



3
4
5
# File 'lib/traver/graph_creator.rb', line 3

def params
  @params
end

#sequencerObject (readonly)

Returns the value of attribute sequencer.



3
4
5
# File 'lib/traver/graph_creator.rb', line 3

def sequencer
  @sequencer
end

Instance Method Details

#create_graphObject



17
18
19
20
21
22
23
# File 'lib/traver/graph_creator.rb', line 17

def create_graph
  object_creator.after_create = lambda do |creator|
    graph.add_vertex(creator.factory_name, creator.object)
  end
  
  object_creator.create_object
end