Class: FormForms::Elements::BaseElement
- Inherits:
-
Object
- Object
- FormForms::Elements::BaseElement
- Defined in:
- lib/form_forms/elements/base_element.rb
Overview
The generic base class for the FormForms
Direct Known Subclasses
Instance Attribute Summary collapse
-
#elements ⇒ Object
readonly
Returns the value of attribute elements.
Instance Method Summary collapse
- #delete(name) ⇒ Object
-
#initialize {|_self| ... } ⇒ BaseElement
constructor
A new instance of BaseElement.
-
#render(builder, view) ⇒ Object
Render all of the elements of the current FormForm in their defined order.
Constructor Details
#initialize {|_self| ... } ⇒ BaseElement
Returns a new instance of BaseElement.
7 8 9 10 11 12 |
# File 'lib/form_forms/elements/base_element.rb', line 7 def initialize(*) @elements = [] @generators = {} yield self end |
Instance Attribute Details
#elements ⇒ Object (readonly)
Returns the value of attribute elements.
14 15 16 |
# File 'lib/form_forms/elements/base_element.rb', line 14 def elements @elements end |
Instance Method Details
#delete(name) ⇒ Object
28 29 30 31 32 |
# File 'lib/form_forms/elements/base_element.rb', line 28 def delete(name) @elements.delete(name) @generators.delete(name) nil end |
#render(builder, view) ⇒ Object
Render all of the elements of the current FormForm in their defined order. This method is expected to be called by sub-classes in the rendering chain. The parameters are a form builder object and an action view instance.
The form builder is typically created by a “special” FormForm class and passed on to its sub-elements. See FormForms::Forms::Form
for an implementation of such a special form.
24 25 26 |
# File 'lib/form_forms/elements/base_element.rb', line 24 def render(builder, view) render_elements(builder, view) end |