Module: Formeze::ClassMethods
Instance Method Summary
collapse
#array_attr_accessor, #array_attr_reader, #array_attr_writer
Instance Method Details
#field(*args) ⇒ Object
188
189
190
191
192
193
194
195
196
197
198
|
# File 'lib/formeze.rb', line 188
def field(*args)
field = Field.new(*args)
fields << field
if field.multiple?
array_attr_accessor field.name
else
attr_accessor field.name
end
end
|
#fields ⇒ Object
184
185
186
|
# File 'lib/formeze.rb', line 184
def fields
@fields ||= FieldSet.new
end
|
#parse(encoded_form_data) ⇒ Object
208
209
210
|
# File 'lib/formeze.rb', line 208
def parse(encoded_form_data)
new.tap { |form| form.parse(encoded_form_data) }
end
|
#validates(field_name, options = {}, &block) ⇒ Object
204
205
206
|
# File 'lib/formeze.rb', line 204
def validates(field_name, options = {}, &block)
validations << Validation.new(fields[field_name], options, &block)
end
|
#validations ⇒ Object
200
201
202
|
# File 'lib/formeze.rb', line 200
def validations
@validations ||= []
end
|