From 51739d3228d12907d60fb1b0a2b1ef96c55f66a3 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Wed, 16 Jun 2010 11:30:37 -0400 Subject: moving before_validation and after_validation functionality from ActiveRecord to ActiveModel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [#4653 state:resolved] Signed-off-by: José Valim --- activemodel/lib/active_model/validations.rb | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'activemodel/lib/active_model/validations.rb') diff --git a/activemodel/lib/active_model/validations.rb b/activemodel/lib/active_model/validations.rb index 57487cf75a..31516dc8a9 100644 --- a/activemodel/lib/active_model/validations.rb +++ b/activemodel/lib/active_model/validations.rb @@ -3,6 +3,7 @@ require 'active_support/core_ext/array/wrap' require 'active_support/core_ext/class/attribute' require 'active_support/core_ext/hash/keys' require 'active_model/errors' +require 'active_model/validations/callbacks' module ActiveModel @@ -45,6 +46,7 @@ module ActiveModel module Validations extend ActiveSupport::Concern include ActiveSupport::Callbacks + include ActiveModel::Validations::Callbacks included do extend ActiveModel::Translation @@ -158,18 +160,6 @@ module ActiveModel @errors ||= Errors.new(self) end - # Runs all the specified validations and returns true if no errors were added - # otherwise false. Context can optionally be supplied to define which callbacks - # to test against (the context is defined on the validations using :on). - def valid?(context = nil) - current_context, self.validation_context = validation_context, context - errors.clear - _run_validate_callbacks - errors.empty? - ensure - self.validation_context = current_context - end - # Performs the opposite of valid?. Returns true if errors were added, # false otherwise. def invalid?(context = nil) -- cgit v1.2.3