Module: Ciesta::ClassMethods
Instance Method Summary collapse
-
#definitions ⇒ Ciesta::FieldList
private
Returns fields definitions.
-
#field(name, **options) ⇒ Object
Declare new form field.
- #proxy ⇒ Object
-
#validate(&block) ⇒ Object
Declare rules for validation.
-
#validator ⇒ Ciesta::Validator
private
Returns form validator.
Instance Method Details
#definitions ⇒ Ciesta::FieldList
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns fields definitions
31 32 33 |
# File 'lib/ciesta/class_methods.rb', line 31 def definitions @definitions ||= {} end |
#field(name, **options) ⇒ Object
Declare new form field
10 11 12 13 14 15 16 17 |
# File 'lib/ciesta/class_methods.rb', line 10 def field(name, **) name = name.to_sym definitions[name] = proxy.instance_eval do define_method(name) { fields[name] } define_method("#{name}=") { |value| fields[name] = value } end end |
#proxy ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/ciesta/class_methods.rb', line 43 def proxy @proxy ||= begin m = Module.new include m m end end |
#validate(&block) ⇒ Object
Declare rules for validation
23 24 25 |
# File 'lib/ciesta/class_methods.rb', line 23 def validate(&block) validator.use(&block) end |
#validator ⇒ Ciesta::Validator
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns form validator
39 40 41 |
# File 'lib/ciesta/class_methods.rb', line 39 def validator @validator ||= Ciesta::Validator.new end |