Class: FormForms::Elements::BaseElement

Inherits:
Object
  • Object
show all
Defined in:
lib/form_forms/elements/base_element.rb

Overview

The generic base class for the FormForms

Direct Known Subclasses

Field, SubForm, TableFields, TableHeader, Forms::BaseForm

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ BaseElement

Returns a new instance of BaseElement.

Yields:

  • (_self)

Yield Parameters:



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

#elementsObject (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