Class: Traver::TraverConstructor
- Inherits:
-
Object
- Object
- Traver::TraverConstructor
- Defined in:
- lib/traver/traver_constructor.rb
Instance Attribute Summary collapse
-
#factories_store ⇒ Object
readonly
Returns the value of attribute factories_store.
-
#sequencer ⇒ Object
readonly
Returns the value of attribute sequencer.
Instance Method Summary collapse
- #create(*options) ⇒ Object
- #create_graph(*options) ⇒ Object
- #create_list(num, *options) ⇒ Object
- #define_factories(&block) ⇒ Object (also: #factories)
- #define_factory(factory_name, *options) ⇒ Object (also: #factory)
- #factories_count ⇒ Object
- #include(*modules) ⇒ Object
-
#initialize ⇒ TraverConstructor
constructor
A new instance of TraverConstructor.
- #undefine_all_factories ⇒ Object
Constructor Details
#initialize ⇒ TraverConstructor
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_store ⇒ Object (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 |
#sequencer ⇒ Object (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(*) factory_name, params = () 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(*) factory_name, params = () 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, *) factory_name, params = () 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, *) parent_factory_name, params = () factories_store.define_factory(factory_name, parent_factory_name, params) end |
#factories_count ⇒ Object
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_factories ⇒ Object
54 55 56 |
# File 'lib/traver/traver_constructor.rb', line 54 def undefine_all_factories factories_store.undefine_all_factories end |