Class: Traver::ObjectCreator
- Inherits:
-
Object
- Object
- Traver::ObjectCreator
- Extended by:
- Forwardable
- Defined in:
- lib/traver/object_creator.rb
Instance Attribute Summary collapse
-
#after_create ⇒ Object
Returns the value of attribute after_create.
-
#cache ⇒ Object
readonly
Returns the value of attribute cache.
-
#factory_definer ⇒ Object
readonly
Returns the value of attribute factory_definer.
-
#factory_name ⇒ Object
readonly
Returns the value of attribute factory_name.
-
#nesting ⇒ Object
readonly
Returns the value of attribute nesting.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#sequencer ⇒ Object
readonly
Returns the value of attribute sequencer.
Class Method Summary collapse
Instance Method Summary collapse
- #create_object ⇒ Object
-
#initialize(factory_name, params, factory_definer, sequencer, cache = {}, nesting = 1) ⇒ ObjectCreator
constructor
A new instance of ObjectCreator.
Constructor Details
#initialize(factory_name, params, factory_definer, sequencer, cache = {}, nesting = 1) ⇒ ObjectCreator
Returns a new instance of ObjectCreator.
23 24 25 26 27 28 29 30 |
# File 'lib/traver/object_creator.rb', line 23 def initialize(factory_name, params, factory_definer, sequencer, cache = {}, nesting = 1) @factory_name = factory_name @params = params @factory_definer = factory_definer @sequencer = sequencer @cache = cache @nesting = nesting end |
Instance Attribute Details
#after_create ⇒ Object
Returns the value of attribute after_create.
10 11 12 |
# File 'lib/traver/object_creator.rb', line 10 def after_create @after_create end |
#cache ⇒ Object (readonly)
Returns the value of attribute cache.
7 8 9 |
# File 'lib/traver/object_creator.rb', line 7 def cache @cache end |
#factory_definer ⇒ Object (readonly)
Returns the value of attribute factory_definer.
7 8 9 |
# File 'lib/traver/object_creator.rb', line 7 def factory_definer @factory_definer end |
#factory_name ⇒ Object (readonly)
Returns the value of attribute factory_name.
7 8 9 |
# File 'lib/traver/object_creator.rb', line 7 def factory_name @factory_name end |
#nesting ⇒ Object (readonly)
Returns the value of attribute nesting.
7 8 9 |
# File 'lib/traver/object_creator.rb', line 7 def nesting @nesting end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
8 9 10 |
# File 'lib/traver/object_creator.rb', line 8 def object @object end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
7 8 9 |
# File 'lib/traver/object_creator.rb', line 7 def params @params end |
#sequencer ⇒ Object (readonly)
Returns the value of attribute sequencer.
7 8 9 |
# File 'lib/traver/object_creator.rb', line 7 def sequencer @sequencer end |
Class Method Details
.create_object(factory_name, params, factory_definer, sequencer, cache = {}, nesting = 1) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/traver/object_creator.rb', line 16 def self.create_object(factory_name, params, factory_definer, sequencer, cache = {}, nesting = 1) creator = new(factory_name, params, factory_definer, sequencer, cache, nesting) creator.create_object creator.object end |
Instance Method Details
#create_object ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/traver/object_creator.rb', line 32 def create_object obtain_factory if obtain_object_from_cache? obtain_object_from_cache else # puts "#{'-' * nesting} #{factory_name}<br/>" change_ref_to_be_empty_hash merge_factory_params merge_default_params instantiate_object set_nested_objects set_attributes persist_object cache_object set_has_one_objects set_nested_collections call_after_create_hook end end |