Class: RgGen::Core::Base::ComponentFactory
- Defined in:
- lib/rggen/core/base/component_factory.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#component_name ⇒ Object
readonly
Returns the value of attribute component_name.
-
#layer ⇒ Object
readonly
Returns the value of attribute layer.
Instance Method Summary collapse
- #create(*args) ⇒ Object
-
#initialize(component_name, layer) ⇒ ComponentFactory
constructor
A new instance of ComponentFactory.
- #root_factory ⇒ Object
Constructor Details
#initialize(component_name, layer) ⇒ ComponentFactory
Returns a new instance of ComponentFactory.
7 8 9 10 11 12 |
# File 'lib/rggen/core/base/component_factory.rb', line 7 def initialize(component_name, layer) @component_name = component_name @layer = layer @root_factory = false block_given? && yield(self) end |
Instance Attribute Details
#component_name ⇒ Object (readonly)
Returns the value of attribute component_name.
14 15 16 |
# File 'lib/rggen/core/base/component_factory.rb', line 14 def component_name @component_name end |
#layer ⇒ Object (readonly)
Returns the value of attribute layer.
15 16 17 |
# File 'lib/rggen/core/base/component_factory.rb', line 15 def layer @layer end |
Instance Method Details
#create(*args) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rggen/core/base/component_factory.rb', line 25 def create(*args) parent, sources = if root_factory? [nil, preprocess(args)] else [args.first, preprocess(args[1..])] end create_component(parent, sources) do |component| build_component(parent, component, sources) root_factory? && finalize(component) end end |
#root_factory ⇒ Object
21 22 23 |
# File 'lib/rggen/core/base/component_factory.rb', line 21 def root_factory @root_factory = true end |