Class: RgGen::Base::ComponentFactory
- Inherits:
-
Object
- Object
- RgGen::Base::ComponentFactory
- Defined in:
- lib/rggen/base/component_factory.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#child_factory ⇒ Object
writeonly
Sets the attribute child_factory.
-
#item_factories ⇒ Object
writeonly
Sets the attribute item_factories.
-
#target_component ⇒ Object
writeonly
Sets the attribute target_component.
Instance Method Summary collapse
- #create(*args) ⇒ Object
-
#initialize ⇒ ComponentFactory
constructor
A new instance of ComponentFactory.
- #root_factory ⇒ Object
Constructor Details
#initialize ⇒ ComponentFactory
Returns a new instance of ComponentFactory.
4 5 6 |
# File 'lib/rggen/base/component_factory.rb', line 4 def initialize @root_factory = false end |
Instance Attribute Details
#child_factory=(value) ⇒ Object (writeonly)
Sets the attribute child_factory
10 11 12 |
# File 'lib/rggen/base/component_factory.rb', line 10 def child_factory=(value) @child_factory = value end |
#item_factories=(value) ⇒ Object (writeonly)
Sets the attribute item_factories
9 10 11 |
# File 'lib/rggen/base/component_factory.rb', line 9 def item_factories=(value) @item_factories = value end |
#target_component=(value) ⇒ Object (writeonly)
Sets the attribute target_component
8 9 10 |
# File 'lib/rggen/base/component_factory.rb', line 8 def target_component=(value) @target_component = value end |
Instance Method Details
#create(*args) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/rggen/base/component_factory.rb', line 12 def create(*args) parent = (child_factory? && args.shift) || nil sources = args create_component(parent, *sources).tap do |component| create_items(component, *sources) if create_items? parent.add_child(component) if child_factory? create_children(component, *sources) if create_children?(component) end end |
#root_factory ⇒ Object
22 23 24 |
# File 'lib/rggen/base/component_factory.rb', line 22 def root_factory @root_factory = true end |