Class: Traver::Factory
- Inherits:
-
Object
- Object
- Traver::Factory
- Defined in:
- lib/traver/factory.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#parent_factory ⇒ Object
readonly
Returns the value of attribute parent_factory.
Instance Method Summary collapse
- #inherited_params ⇒ Object
-
#initialize(name, params, parent_factory) ⇒ Factory
constructor
A new instance of Factory.
- #object_class ⇒ Object
- #object_class_name ⇒ Object
- #root_factory ⇒ Object
- #root_name ⇒ Object
Constructor Details
#initialize(name, params, parent_factory) ⇒ Factory
Returns a new instance of Factory.
5 6 7 8 9 |
# File 'lib/traver/factory.rb', line 5 def initialize(name, params, parent_factory) @name = name @params = params @parent_factory = parent_factory end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/traver/factory.rb', line 3 def name @name end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
3 4 5 |
# File 'lib/traver/factory.rb', line 3 def params @params end |
#parent_factory ⇒ Object (readonly)
Returns the value of attribute parent_factory.
3 4 5 |
# File 'lib/traver/factory.rb', line 3 def parent_factory @parent_factory end |
Instance Method Details
#inherited_params ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/traver/factory.rb', line 23 def inherited_params if parent_factory parent_factory.inherited_params.merge(params) else params end end |
#object_class ⇒ Object
35 36 37 |
# File 'lib/traver/factory.rb', line 35 def object_class Object.const_get(object_class_name) end |
#object_class_name ⇒ Object
31 32 33 |
# File 'lib/traver/factory.rb', line 31 def object_class_name root_factory.name.to_s.camelize end |
#root_factory ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/traver/factory.rb', line 11 def root_factory if parent_factory parent_factory.root_factory else self end end |
#root_name ⇒ Object
19 20 21 |
# File 'lib/traver/factory.rb', line 19 def root_name root_factory.name end |