Class: Reform::Contract

Inherits:
Disposable::Twin
  • Object
show all
Extended by:
ValidatesWarning, Schema
Includes:
Expose, Readonly, Validate
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

Form

Defined Under Namespace

Modules: Readonly, Validate, ValidatesWarning Classes: Errors

Class Method Summary collapse

Methods included from ValidatesWarning

validates

Methods included from Schema

schema

Methods included from Readonly

#options_for, #readonly?

Methods included from Validate

#errors, #validate, #validate!

Class Method Details

.properties(*args) ⇒ Object

FIXME: test me.



38
39
40
41
# File 'lib/reform/contract.rb', line 38

def self.properties(*args)
  options = args.extract_options!
  args.each { |name| property(name, options.dup) }
end

.property(name, options = {}, &block) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/reform/contract.rb', line 23

def self.property(name, options={}, &block)
  if twin = options.delete(:form)
    options[:twin] = twin
  end

  options[:pass_options] = true

  if validates_options = options[:validates]
    validates name, validates_options.dup # .dup for RAils 3.x.
  end

  super
end