From 05d4653cef1c1d8d77228de26d55cf6d6a0ce20b Mon Sep 17 00:00:00 2001 From: Myron Marston Date: Thu, 28 Apr 2011 07:58:58 -0700 Subject: Revert "Revert "Handle enabling/disabling observers at different levels of the class hierarchy."" This reverts commit 2a25c5818b03d7d6cd63aad180bff23479dbd861. I'm going to add another commit that keeps the same behavior of fixes the problems of leaking memory in development. --- activemodel/lib/active_model/observing.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'activemodel/lib/active_model/observing.rb') diff --git a/activemodel/lib/active_model/observing.rb b/activemodel/lib/active_model/observing.rb index e1a2ce218d..ba6be46670 100644 --- a/activemodel/lib/active_model/observing.rb +++ b/activemodel/lib/active_model/observing.rb @@ -70,6 +70,10 @@ module ActiveModel observer_instances.size end + def subclasses + @subclasses ||= [] + end + protected def instantiate_observer(observer) #:nodoc: # string/symbol @@ -89,6 +93,7 @@ module ActiveModel # Notify observers when the observed class is subclassed. def inherited(subclass) super + subclasses << subclass notify_observers :observed_class_inherited, subclass end end -- cgit v1.2.3