Class: RgGen::Base::ComponentFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/rggen/base/component_factory.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeComponentFactory

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

Parameters:

  • value

    the value to set the attribute child_factory to.



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

Parameters:

  • value

    the value to set the attribute item_factories to.



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

Parameters:

  • value

    the value to set the attribute target_component to.



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_factoryObject



22
23
24
# File 'lib/rggen/base/component_factory.rb', line 22

def root_factory
  @root_factory = true
end