Class: Amrita2View::FormHelper::FormFieldHelper
- Includes:
- Amrita2::DictionaryData
- Defined in:
- lib/amrita2/rails_bridge.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#form ⇒ Object
readonly
Returns the value of attribute form.
Instance Method Summary collapse
- #add_field(name, value) ⇒ Object
- #add_field_element(name, element) ⇒ Object
- #as_hash ⇒ Object
- #as_label_field_hash ⇒ Object
-
#initialize(record, form, &block) ⇒ FormFieldHelper
constructor
A new instance of FormFieldHelper.
- #method_missing(meth, name, *args, &block) ⇒ Object
Methods included from Amrita2::DictionaryData
Constructor Details
#initialize(record, form, &block) ⇒ FormFieldHelper
Returns a new instance of FormFieldHelper.
21 22 23 24 25 26 |
# File 'lib/amrita2/rails_bridge.rb', line 21 def initialize(record, form, &block) @record = record @form = form @data = {} block.call(self) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, name, *args, &block) ⇒ Object
36 37 38 39 |
# File 'lib/amrita2/rails_bridge.rb', line 36 def method_missing(meth, name, *args, &block) value = @form.send(meth, name, *args, &block) add_field_element(name, value) end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
19 20 21 |
# File 'lib/amrita2/rails_bridge.rb', line 19 def data @data end |
#form ⇒ Object (readonly)
Returns the value of attribute form.
19 20 21 |
# File 'lib/amrita2/rails_bridge.rb', line 19 def form @form end |
Instance Method Details
#add_field(name, value) ⇒ Object
28 29 30 |
# File 'lib/amrita2/rails_bridge.rb', line 28 def add_field(name, value) @data[name] = value end |
#add_field_element(name, element) ⇒ Object
32 33 34 |
# File 'lib/amrita2/rails_bridge.rb', line 32 def add_field_element(name, element) add_field(name, Amrita2::SanitizedString[element]) end |
#as_hash ⇒ Object
41 42 43 |
# File 'lib/amrita2/rails_bridge.rb', line 41 def as_hash @data end |