Skip to content

Commit

Permalink
Revert "Run callbacks from object's metaclass"
Browse files Browse the repository at this point in the history
This reverts commit e0846c8.
  • Loading branch information
josh committed Jul 16, 2008
1 parent 7a84681 commit 82f3386
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 35 deletions.
2 changes: 0 additions & 2 deletions activesupport/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
*2.1.1 (next release)*

* Run callbacks from object's metaclass [Josh Peek]

* TimeWithZone: when crossing DST boundary, treat Durations of days, months or years as variable-length, and all other values as absolute length. A time + 24.hours will advance exactly 24 hours, but a time + 1.day will advance 23-25 hours, depending on the day. Ensure consistent behavior across all advancing methods [Geoff Buesing]

* Fix TimeWithZone unmarshaling: coerce unmarshaled Time instances to utc, because Ruby's marshaling of Time instances doesn't respect the zone [Geoff Buesing]
Expand Down
10 changes: 1 addition & 9 deletions activesupport/lib/active_support/callbacks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -269,15 +269,7 @@ def self.#{callback}_callback_chain
# 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
24 changes: 0 additions & 24 deletions activesupport/test/callbacks_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,30 +84,6 @@ def test_save_person
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
Expand Down

0 comments on commit 82f3386

Please sign in to comment.