class Reform::Contract

Define your form structure and its validations. Instantiate it with a model, and then validate this object graph.

Public Class Methods

default_nested_class() click to toggle source
# File lib/reform/contract.rb, line 13
def self.default_nested_class
  Contract
end
properties(*args) click to toggle source
# File lib/reform/contract.rb, line 29
def self.properties(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  args.each { |name| property(name, options.dup) }
end
property(name, options = {}, &block) click to toggle source
Calls superclass method
# File lib/reform/contract.rb, line 17
def self.property(name, options = {}, &block)
  if twin = options.delete(:form)
    options[:twin] = twin
  end

  if validates_options = options[:validates]
    validates name, validates_options
  end

  super
end

Private Class Methods

clone() click to toggle source
# File lib/reform/contract.rb, line 63
def self.clone # TODO: test. THIS IS ONLY FOR Trailblazer when contract gets cloned in suboperation.
  Class.new(self)
end
options_for(name) click to toggle source
# File lib/reform/contract.rb, line 58
def self.options_for(name)
  definitions.get(name)
end