From d8a72b32c5b0c32abf257f05b89bad7d21f178ec Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Wed, 16 Jul 2008 20:23:44 -0500 Subject: Revert "Run callbacks from object's metaclass" --- activesupport/CHANGELOG | 2 -- activesupport/lib/active_support/callbacks.rb | 10 +--------- activesupport/test/callbacks_test.rb | 24 ------------------------ 3 files changed, 1 insertion(+), 35 deletions(-) (limited to 'activesupport') diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG index aa383cd166..8d3b136d80 100644 --- a/activesupport/CHANGELOG +++ b/activesupport/CHANGELOG @@ -1,7 +1,5 @@ *Edge* -* Run callbacks from object's metaclass [Josh Peek] - * Add Array#in_groups which splits or iterates over the array in specified number of groups. #579. [Adrian Mugnolo] Example: a = (1..10).to_a diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb index f125a56246..9c59b7ac76 100644 --- a/activesupport/lib/active_support/callbacks.rb +++ b/activesupport/lib/active_support/callbacks.rb @@ -269,15 +269,7 @@ module ActiveSupport # pass # stop def run_callbacks(kind, options = {}, &block) - callback_chain_method = "#{kind}_callback_chain" - - # Meta class inherits Class so we don't have to merge it in 1.9 - if RUBY_VERSION >= '1.9' - metaclass.send(callback_chain_method).run(self, options, &block) - else - callbacks = self.class.send(callback_chain_method) | metaclass.send(callback_chain_method) - callbacks.run(self, options, &block) - end + self.class.send("#{kind}_callback_chain").run(self, options, &block) end end end diff --git a/activesupport/test/callbacks_test.rb b/activesupport/test/callbacks_test.rb index c3f683bdb5..7f71ca2262 100644 --- a/activesupport/test/callbacks_test.rb +++ b/activesupport/test/callbacks_test.rb @@ -84,30 +84,6 @@ class CallbacksTest < Test::Unit::TestCase end end -class MetaclassCallbacksTest < Test::Unit::TestCase - module ModuleWithCallbacks - def self.extended(object) - object.metaclass.before_save :raise_metaclass_callback_called - end - - def module_callback_called? - @module_callback_called ||= false - end - - def raise_metaclass_callback_called - @module_callback_called = true - end - end - - def test_metaclass_callbacks - person = Person.new - person.extend(ModuleWithCallbacks) - assert !person.module_callback_called? - person.save - assert person.module_callback_called? - end -end - class ConditionalCallbackTest < Test::Unit::TestCase def test_save_conditional_person person = ConditionalPerson.new -- cgit v1.2.3