diff options
author | José Valim <jose.valim@gmail.com> | 2012-04-24 23:09:48 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2012-04-24 23:09:48 -0700 |
commit | cd556c9388171bff263825d3066ef440a00d01b3 (patch) | |
tree | eae7d7c9a6a51a10ae44b00805e0502ce46983f7 /activemodel | |
parent | a837b30f8450ceac3813983b8ee3b90be5f2898a (diff) | |
parent | 27d6ccd8c86cffaa5f74ebfb6861ece429172854 (diff) | |
download | rails-cd556c9388171bff263825d3066ef440a00d01b3.tar.gz rails-cd556c9388171bff263825d3066ef440a00d01b3.tar.bz2 rails-cd556c9388171bff263825d3066ef440a00d01b3.zip |
Merge pull request #5841 from oscardelben/rename_count_observers
Rename Observing#count_observers to Observing#observers_count
Diffstat (limited to 'activemodel')
-rw-r--r-- | activemodel/lib/active_model/observing.rb | 9 | ||||
-rw-r--r-- | activemodel/test/cases/observing_test.rb | 2 |
2 files changed, 9 insertions, 2 deletions
diff --git a/activemodel/lib/active_model/observing.rb b/activemodel/lib/active_model/observing.rb index fc84b52dd9..a6b6dfafe7 100644 --- a/activemodel/lib/active_model/observing.rb +++ b/activemodel/lib/active_model/observing.rb @@ -4,6 +4,7 @@ require 'active_support/core_ext/module/aliasing' require 'active_support/core_ext/module/remove_method' require 'active_support/core_ext/string/inflections' require 'active_support/core_ext/enumerable' +require 'active_support/deprecation' require 'active_support/descendants_tracker' module ActiveModel @@ -74,10 +75,16 @@ module ActiveModel end # Total number of observers. - def count_observers + def observers_count observer_instances.size end + def count_observers + msg = "count_observers is deprecated in favor of observers_count" + ActiveSupport::Deprecation.warn(msg) + observers_count + end + protected def instantiate_observer(observer) #:nodoc: # string/symbol diff --git a/activemodel/test/cases/observing_test.rb b/activemodel/test/cases/observing_test.rb index f6ec24ae57..df070d2d8e 100644 --- a/activemodel/test/cases/observing_test.rb +++ b/activemodel/test/cases/observing_test.rb @@ -73,7 +73,7 @@ class ObservingTest < ActiveModel::TestCase test "passes observers to subclasses" do FooObserver.instance bar = Class.new(Foo) - assert_equal Foo.count_observers, bar.count_observers + assert_equal Foo.observers_count, bar.observers_count end end |