mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #5841 from oscardelben/rename_count_observers
Rename Observing#count_observers to Observing#observers_count
This commit is contained in:
commit
cd556c9388
2 changed files with 9 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue