diff options
author | Joshua Peek <josh@joshpeek.com> | 2008-04-20 11:45:44 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2008-04-20 11:45:44 -0500 |
commit | 46ab7422d9ebac0d529f71a3a7c2feaf0b9d5dbd (patch) | |
tree | b8b28b08ced54f68137f43d796db00ffd8205b89 /activemodel/lib/active_model/validations.rb | |
parent | 14a40804a29a57ad05ca6bffbe1e5334089593a9 (diff) | |
download | rails-46ab7422d9ebac0d529f71a3a7c2feaf0b9d5dbd.tar.gz rails-46ab7422d9ebac0d529f71a3a7c2feaf0b9d5dbd.tar.bz2 rails-46ab7422d9ebac0d529f71a3a7c2feaf0b9d5dbd.zip |
Use define_callbacks helper for ActiveRecord validations.
Diffstat (limited to 'activemodel/lib/active_model/validations.rb')
-rw-r--r-- | activemodel/lib/active_model/validations.rb | 18 |
1 files changed, 1 insertions, 17 deletions
diff --git a/activemodel/lib/active_model/validations.rb b/activemodel/lib/active_model/validations.rb index 3b7b9050be..b15bdb06ca 100644 --- a/activemodel/lib/active_model/validations.rb +++ b/activemodel/lib/active_model/validations.rb @@ -3,23 +3,7 @@ module ActiveModel def self.included(base) # :nodoc: base.extend(ClassMethods) base.send!(:include, ActiveSupport::Callbacks) - - %w( validate validate_on_create validate_on_update ).each do |validation_method| - base.class_eval <<-"end_eval" - def self.#{validation_method}(*methods, &block) - self.#{validation_method}_callback_chain | CallbackChain.build(:#{validation_method}, *methods, &block) - end - - def self.#{validation_method}_callback_chain - if chain = read_inheritable_attribute(:#{validation_method}) - return chain - else - write_inheritable_attribute(:#{validation_method}, CallbackChain.new) - return #{validation_method}_callback_chain - end - end - end_eval - end + base.define_callbacks :validate, :validate_on_create, :validate_on_update end module ClassMethods |