Class: Reform::Contract
- Inherits:
-
Disposable::Twin
- Object
- Disposable::Twin
- Reform::Contract
- Includes:
- Disposable::Twin::Sync, Expose, Readonly, Validate, Validation
- Defined in:
- lib/reform/contract.rb
Overview
Define your form structure and its validations. Instantiate it with a model, and then validate
this object graph.
Direct Known Subclasses
Defined Under Namespace
Modules: Readonly, Validate Classes: Errors
Instance Attribute Summary
Attributes included from Validate
Class Method Summary collapse
- .default_nested_class ⇒ Object
-
.properties(*args) ⇒ Object
FIXME: test me.
- .property(name, options = {}, &block) ⇒ Object
Methods included from Readonly
Methods included from Validation
Methods included from Validate
#initialize, #validate, #validate!
Class Method Details
.default_nested_class ⇒ Object
14 15 16 |
# File 'lib/reform/contract.rb', line 14 def self.default_nested_class Contract end |
.properties(*args) ⇒ Object
FIXME: test me.
31 32 33 34 |
# File 'lib/reform/contract.rb', line 31 def self.properties(*args) = args.last.is_a?(Hash) ? args.pop : {} args.each { |name| property(name, .dup) } end |
.property(name, options = {}, &block) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/reform/contract.rb', line 18 def self.property(name, ={}, &block) if twin = .delete(:form) [:twin] = twin end if = [:validates] validates name, end super end |