aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/observing.rb
diff options
context:
space:
mode:
authorMyron Marston <myron.marston@gmail.com>2011-04-28 07:58:58 -0700
committerMyron Marston <myron.marston@gmail.com>2011-04-28 07:58:58 -0700
commit05d4653cef1c1d8d77228de26d55cf6d6a0ce20b (patch)
tree6d83604f9b4e2d5fca96bc43d41fe83444116081 /activemodel/lib/active_model/observing.rb
parentbf50222b0b5417af554a9a4a8d277f4fccea8f8c (diff)
downloadrails-05d4653cef1c1d8d77228de26d55cf6d6a0ce20b.tar.gz
rails-05d4653cef1c1d8d77228de26d55cf6d6a0ce20b.tar.bz2
rails-05d4653cef1c1d8d77228de26d55cf6d6a0ce20b.zip
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.
Diffstat (limited to 'activemodel/lib/active_model/observing.rb')
-rw-r--r--activemodel/lib/active_model/observing.rb5
1 files changed, 5 insertions, 0 deletions
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