Sha256: 986a9860aacc0afcd5f5be8a4a64b8994d81caaff3a8a0fb20118f67610f6e94
Contents?: true
Size: 1.64 KB
Versions: 1
Compression:
Stored size: 1.64 KB
Contents
require "uber/inheritable_attr" module Reform # Define your form structure and its validations. Instantiate it with a model, # and then +validate+ this object graph. class Contract < Disposable::Twin require "disposable/twin/composition" # Expose. include Expose feature Setup feature Setup::SkipSetter feature Default def self.default_nested_class Contract end 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 # FIXME: test me. def self.properties(*args) options = args.extract_options! args.each { |name| property(name, options.dup) } end require 'reform/contract/validate' include Reform::Contract::Validate require "reform/validation" include Reform::Validation # ::validates and #valid? # module ValidatesWarning # def validates(*) # raise "[Reform] Please include either Reform::Form::ActiveModel::Validations or Reform::Form::Lotus in your form class." # end # end # extend ValidatesWarning private # DISCUSS: separate file? module Readonly def readonly?(name) options_for(name)[:writeable] == false end def options_for(name) self.class.options_for(name) end end def self.options_for(name) definitions.get(name) end include Readonly def self.clone # TODO: test. THIS IS ONLY FOR Trailblazer when contract gets cloned in suboperation. Class.new(self) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
reform-2.1.0.rc1 | lib/reform/contract.rb |