Class: ProMotion::XLForm
- Inherits:
-
Object
- Object
- ProMotion::XLForm
- Includes:
- XLFormCellBuilder, XLFormHelper, XLFormSectionBuilder
- Defined in:
- lib/ProMotion/XLForm/xl_form.rb
Instance Attribute Summary collapse
-
#form_data ⇒ Object
readonly
Returns the value of attribute form_data.
Instance Method Summary collapse
- #build ⇒ Object
- #get_callback(descriptor, event) ⇒ Object
-
#initialize(form_data, opts = {}) ⇒ XLForm
constructor
A new instance of XLForm.
Methods included from XLFormSectionBuilder
Methods included from XLFormCellBuilder
Methods included from XLFormHelper
Constructor Details
#initialize(form_data, opts = {}) ⇒ XLForm
Returns a new instance of XLForm.
10 11 12 13 14 15 |
# File 'lib/ProMotion/XLForm/xl_form.rb', line 10 def initialize(form_data, opts={}) @form_data = form_data @title = opts[:title] || '' @required = opts[:required] @auto_focus = opts[:auto_focus] end |
Instance Attribute Details
#form_data ⇒ Object (readonly)
Returns the value of attribute form_data.
8 9 10 |
# File 'lib/ProMotion/XLForm/xl_form.rb', line 8 def form_data @form_data end |
Instance Method Details
#build ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ProMotion/XLForm/xl_form.rb', line 17 def build form = XLFormDescriptor.formDescriptorWithTitle(@title) form.addAsteriskToRequiredRowsTitle = (@required == :asterisks) # focus on this cell if @auto_focus form.assignFirstResponderOnShow = true end form_data.each do |section_data| section = create_section(section_data) form.addFormSection(section) end form end |
#get_callback(descriptor, event) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/ProMotion/XLForm/xl_form.rb', line 35 def get_callback(descriptor, event) tag = descriptor.respond_to?(:multivaluedTag) ? descriptor.multivaluedTag : descriptor.tag return if @blocks.nil? || @blocks[tag].nil? || @blocks[tag][event].nil? @blocks[tag][event] end |