From d916c62cfc7c59ab6411407a05b946d3dd7535e9 Mon Sep 17 00:00:00 2001 From: wycats Date: Sun, 9 May 2010 02:06:05 +0300 Subject: eliminate alias_method_chain from ActiveRecord --- activerecord/lib/active_record/callbacks.rb | 48 ++++++++++------------------- 1 file changed, 16 insertions(+), 32 deletions(-) (limited to 'activerecord/lib/active_record/callbacks.rb') diff --git a/activerecord/lib/active_record/callbacks.rb b/activerecord/lib/active_record/callbacks.rb index 7ebeb6079e..498836aca4 100644 --- a/activerecord/lib/active_record/callbacks.rb +++ b/activerecord/lib/active_record/callbacks.rb @@ -233,10 +233,6 @@ module ActiveRecord ] included do - [:create_or_update, :valid?, :create, :update, :destroy].each do |method| - alias_method_chain method, :callbacks - end - extend ActiveModel::Callbacks define_callbacks :validation, :terminator => "result == false", :scope => [:kind, :name] @@ -273,45 +269,33 @@ module ActiveRecord end end - def create_or_update_with_callbacks #:nodoc: - _run_save_callbacks do - create_or_update_without_callbacks - end + def valid?(*) #:nodoc: + @_on_validate = new_record? ? :create : :update + _run_validation_callbacks { super } end - private :create_or_update_with_callbacks - def create_with_callbacks #:nodoc: - _run_create_callbacks do - create_without_callbacks - end + def destroy #:nodoc: + _run_destroy_callbacks { super } end - private :create_with_callbacks - def update_with_callbacks(*args) #:nodoc: - _run_update_callbacks do - update_without_callbacks(*args) + def deprecated_callback_method(symbol) #:nodoc: + if respond_to?(symbol, true) + ActiveSupport::Deprecation.warn("Overwriting #{symbol} in your models has been deprecated, please use Base##{symbol} :method_name instead") + send(symbol) end end - private :update_with_callbacks - def valid_with_callbacks? #:nodoc: - @_on_validate = new_record? ? :create : :update - _run_validation_callbacks do - valid_without_callbacks? - end + private + def create_or_update #:nodoc: + _run_save_callbacks { super } end - def destroy_with_callbacks #:nodoc: - _run_destroy_callbacks do - destroy_without_callbacks - end + def create #:nodoc: + _run_create_callbacks { super } end - def deprecated_callback_method(symbol) #:nodoc: - if respond_to?(symbol, true) - ActiveSupport::Deprecation.warn("Overwriting #{symbol} in your models has been deprecated, please use Base##{symbol} :method_name instead") - send(symbol) - end + def update(*) #:nodoc: + _run_update_callbacks { super } end end end -- cgit v1.2.3