Class: Traver::TraverConstructor

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTraverConstructor

Returns a new instance of TraverConstructor.



5
6
7
8
# File 'lib/traver/traver_constructor.rb', line 5

def initialize
  @factories_store = FactoriesStore.new
  @sequencer       = Sequencer.new
end

Instance Attribute Details

#factories_storeObject (readonly)

Returns the value of attribute factories_store.



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

def factories_store
  @factories_store
end

#sequencerObject (readonly)

Returns the value of attribute sequencer.



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

def sequencer
  @sequencer
end

Instance Method Details

#create(*options) ⇒ Object



16
17
18
19
20
# File 'lib/traver/traver_constructor.rb', line 16

def create(*options)
  factory_name, params = parse_create_options(options)
  
  ObjectCreator.create_object(factory_name, params, factories_store, sequencer)
end

#create_graph(*options) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/traver/traver_constructor.rb', line 22

def create_graph(*options)
  factory_name, params = parse_create_options(options)

  graph_creator = GraphCreator.new(factory_name, params, factories_store, sequencer)
  graph_creator.create_graph

  graph_creator.graph
end

#create_list(num, *options) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/traver/traver_constructor.rb', line 31

def create_list(num, *options)
  factory_name, params = parse_create_options(options)
  
  list_creator = ListCreator.new(num, factory_name, params, factories_store, sequencer)
  list_creator.create_list
  
  list_creator.list
end

#define_factories(&block) ⇒ Object Also known as: factories



40
41
42
# File 'lib/traver/traver_constructor.rb', line 40

def define_factories(&block)
  instance_exec(&block)
end

#define_factory(factory_name, *options) ⇒ Object Also known as: factory



46
47
48
49
50
# File 'lib/traver/traver_constructor.rb', line 46

def define_factory(factory_name, *options)
  parent_factory_name, params = parse_factory_options(options)

  factories_store.define_factory(factory_name, parent_factory_name, params)
end

#factories_countObject



58
59
60
# File 'lib/traver/traver_constructor.rb', line 58

def factories_count
  factories_store.factories_count
end

#include(*modules) ⇒ Object



10
11
12
13
14
# File 'lib/traver/traver_constructor.rb', line 10

def include(*modules)
  modules.each do |mod|
    self.class.include(mod)
  end
end

#undefine_all_factoriesObject



54
55
56
# File 'lib/traver/traver_constructor.rb', line 54

def undefine_all_factories
  factories_store.undefine_all_factories
end