Class: Reform::Contract
- Inherits:
-
Object
- Object
- Reform::Contract
- Extended by:
- PropertyMethods, Schema, Uber::Delegates, Uber::InheritableAttr
- Defined in:
- lib/reform/contract.rb,
lib/reform/contract/setup.rb
Overview
Gives you a DSL for defining the object structure and its validations.
Direct Known Subclasses
Defined Under Namespace
Modules: PropertyMethods, Setup, Validate Classes: Errors, Fields
Constant Summary collapse
- RESERVED_METHODS =
TODO: refactor that so we don’t need that.
[:model, :aliased_model, :fields, :mapper]
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
FIXME: this is needed for Rails 3.0 compatibility.
-
#model ⇒ Object
(also: #aliased_model)
Returns the value of attribute model.
Class Method Summary collapse
- .representer(name = nil, options = {}, &block) ⇒ Object
-
.representers ⇒ Object
keeps all transformation representers for one class.
Methods included from PropertyMethods
collection, properties, property, setup_form_definition
Methods included from Schema
Methods included from Validate
Methods included from Setup
#create_fields, #initialize, #setup_fields, #setup_representer
Methods included from Setup::Readable
Methods included from Setup::SetupOptions
Instance Attribute Details
#errors ⇒ Object
FIXME: this is needed for Rails 3.0 compatibility.
134 135 136 |
# File 'lib/reform/contract.rb', line 134 def errors # FIXME: this is needed for Rails 3.0 compatibility. @errors ||= Errors.new(self) end |
#model ⇒ Object Also known as: aliased_model
Returns the value of attribute model.
112 113 114 |
# File 'lib/reform/contract.rb', line 112 def model @model end |
Class Method Details
.representer(name = nil, options = {}, &block) ⇒ Object
121 122 123 124 125 126 127 128 129 |
# File 'lib/reform/contract.rb', line 121 def self.representer(name=nil, ={}, &block) return representer_class.each(&block) if name == nil return representers[name] if representers[name] # don't run block as this representer is already setup for this form class. only_forms = [:all] ? false : true base = [:superclass] || representer_class representers[name] = Class.new(base).each(only_forms, &block) # let user modify representer. end |
.representers ⇒ Object
keeps all transformation representers for one class.
117 118 119 |
# File 'lib/reform/contract.rb', line 117 def self.representers # keeps all transformation representers for one class. @representers ||= {} end |