Class: ProMotion::Form
- Inherits:
-
Object
- Object
- ProMotion::Form
- Defined in:
- lib/ProMotion/form/form.rb
Instance Attribute Summary collapse
-
#form_data ⇒ Object
readonly
Returns the value of attribute form_data.
Instance Method Summary collapse
-
#build ⇒ Object
Smartly creates a “dumb” FXForms-compatible form object.
-
#initialize(form_data) ⇒ Form
constructor
A new instance of Form.
Constructor Details
#initialize(form_data) ⇒ Form
Returns a new instance of Form.
5 6 7 |
# File 'lib/ProMotion/form/form.rb', line 5 def initialize(form_data) @form_data = form_data end |
Instance Attribute Details
#form_data ⇒ Object (readonly)
Returns the value of attribute form_data.
3 4 5 |
# File 'lib/ProMotion/form/form.rb', line 3 def form_data @form_data end |
Instance Method Details
#build ⇒ Object
Smartly creates a “dumb” FXForms-compatible form object. It contains the values for every field and also has the instructions on how to build the form.
12 13 14 15 16 17 18 19 20 |
# File 'lib/ProMotion/form/form.rb', line 12 def build props = properties form_struct = Struct.new(:fields, *props) do props.each do |p| alias_method "set#{p.capitalize}:", "#{p}=" end end form_struct.new(form_fields, *values) end |