Class: ProMotion::Form

Inherits:
Object
  • Object
show all
Defined in:
lib/ProMotion/form/form.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_dataObject (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

#buildObject

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