Class: Field::Form
- Extended by:
- FormProxy
- Defined in:
- lib/field/form.rb
Instance Attribute Summary collapse
-
#form_class ⇒ Object
Returns the value of attribute form_class.
Attributes inherited from Base
Instance Method Summary collapse
Methods included from FormProxy
Methods inherited from Base
factory, #initialize, #presenter_class, #setup_container, #value
Constructor Details
This class inherits a constructor from Field::Base
Instance Attribute Details
#form_class ⇒ Object
Returns the value of attribute form_class.
7 8 9 |
# File 'lib/field/form.rb', line 7 def form_class @form_class end |
Instance Method Details
#attribute ⇒ Object
26 27 28 |
# File 'lib/field/form.rb', line 26 def attribute @form_class end |
#inject_attributes ⇒ Object
9 10 11 |
# File 'lib/field/form.rb', line 9 def inject_attributes @container.attribute @name, attribute, default: attribute.new end |
#inject_validations ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/field/form.rb', line 13 def inject_validations @container.class_eval %Q{ method = "__ensure_valid_#{name.to_s}__" validate method define_method method do unless send('#{name}').send(:valid?) errors.add(:base, "Invalid #{name.to_s}") end end } end |