diff options
author | José Valim <jose.valim@gmail.com> | 2011-04-28 09:32:57 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-04-28 09:32:57 +0200 |
commit | 2a25c5818b03d7d6cd63aad180bff23479dbd861 (patch) | |
tree | 251fa94604fc45a6edf273fb089ff0fe8181ff58 /activemodel/lib/active_model | |
parent | 5297049e32c3b176893e7ef029d9fa22f2003409 (diff) | |
download | rails-2a25c5818b03d7d6cd63aad180bff23479dbd861.tar.gz rails-2a25c5818b03d7d6cd63aad180bff23479dbd861.tar.bz2 rails-2a25c5818b03d7d6cd63aad180bff23479dbd861.zip |
Revert "Handle enabling/disabling observers at different levels of the class hierarchy."
This reverts commit ad62f1928768bd2676958a4a08512bad342fe469 because the current
subclasses implementation leaks memory in development.
Instead of keeping an array of subclasses, the better solution is to
ask the parent if an observer is being disabled or not.
Diffstat (limited to 'activemodel/lib/active_model')
-rw-r--r-- | activemodel/lib/active_model/observer_array.rb | 34 | ||||
-rw-r--r-- | activemodel/lib/active_model/observing.rb | 5 |
2 files changed, 3 insertions, 36 deletions
diff --git a/activemodel/lib/active_model/observer_array.rb b/activemodel/lib/active_model/observer_array.rb index f3b5811b81..b8aa9cc1e2 100644 --- a/activemodel/lib/active_model/observer_array.rb +++ b/activemodel/lib/active_model/observer_array.rb @@ -48,7 +48,7 @@ module ActiveModel set_enablement(true, observers, &block) end - protected + private def observer_class_for(observer) return observer if observer.is_a?(Class) @@ -61,37 +61,13 @@ module ActiveModel end end - def start_transaction - disabled_observer_stack.push(disabled_observers.dup) - each_subclass_array do |array| - array.start_transaction - end - end - - def disabled_observer_stack - @disabled_observer_stack ||= [] - end - - def end_transaction - @disabled_observers = disabled_observer_stack.pop - each_subclass_array do |array| - array.end_transaction - end - end - def transaction - start_transaction + orig_disabled_observers = disabled_observers.dup begin yield ensure - end_transaction - end - end - - def each_subclass_array - model_class.subclasses.each do |subclass| - yield self.class.for(subclass) + @disabled_observers = orig_disabled_observers end end @@ -116,10 +92,6 @@ module ActiveModel disabled_observers << klass end end - - each_subclass_array do |array| - array.set_enablement(enabled, observers) - end end end end diff --git a/activemodel/lib/active_model/observing.rb b/activemodel/lib/active_model/observing.rb index ba6be46670..e1a2ce218d 100644 --- a/activemodel/lib/active_model/observing.rb +++ b/activemodel/lib/active_model/observing.rb @@ -70,10 +70,6 @@ module ActiveModel observer_instances.size end - def subclasses - @subclasses ||= [] - end - protected def instantiate_observer(observer) #:nodoc: # string/symbol @@ -93,7 +89,6 @@ module ActiveModel # Notify observers when the observed class is subclassed. def inherited(subclass) super - subclasses << subclass notify_observers :observed_class_inherited, subclass end end |