diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2019-06-03 05:47:10 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2019-06-03 05:47:10 +0900 |
commit | 90d6237762da832d0c6302b31fd68d3efb771c64 (patch) | |
tree | 8147e46c31395e9a0db3cb60ef38dcc34ad50119 /activesupport/lib | |
parent | c3ca9b00e3c5f839311c55549f25f7afe8120f9d (diff) | |
download | rails-90d6237762da832d0c6302b31fd68d3efb771c64.tar.gz rails-90d6237762da832d0c6302b31fd68d3efb771c64.tar.bz2 rails-90d6237762da832d0c6302b31fd68d3efb771c64.zip |
Fix `subscribed` with no pattern to subscribe all messages
This is a regression for #36184.
And also, add new `monotonic` argument to the last of the method
signature rather than the first.
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/notifications.rb | 14 | ||||
-rw-r--r-- | activesupport/lib/active_support/notifications/fanout.rb | 6 |
2 files changed, 9 insertions, 11 deletions
diff --git a/activesupport/lib/active_support/notifications.rb b/activesupport/lib/active_support/notifications.rb index 555c0ad1d3..a7a6112b0f 100644 --- a/activesupport/lib/active_support/notifications.rb +++ b/activesupport/lib/active_support/notifications.rb @@ -231,18 +231,16 @@ module ActiveSupport # ActiveSupport::Notifications.subscribe(/render/) do |event| # @event = event # end - def subscribe(*args, &block) - pattern, callback = *args - notifier.subscribe(pattern, callback, false, &block) + def subscribe(pattern = nil, callback = nil, &block) + notifier.subscribe(pattern, callback, monotonic: false, &block) end - def monotonic_subscribe(*args, &block) - pattern, callback = *args - notifier.subscribe(pattern, callback, true, &block) + def monotonic_subscribe(pattern = nil, callback = nil, &block) + notifier.subscribe(pattern, callback, monotonic: true, &block) end - def subscribed(callback, pattern, monotonic: false, &block) - subscriber = notifier.subscribe(pattern, callback, monotonic) + def subscribed(callback, pattern = nil, monotonic: false, &block) + subscriber = notifier.subscribe(pattern, callback, monotonic: monotonic) yield ensure unsubscribe(subscriber) diff --git a/activesupport/lib/active_support/notifications/fanout.rb b/activesupport/lib/active_support/notifications/fanout.rb index c37bec4ee5..aa602329ec 100644 --- a/activesupport/lib/active_support/notifications/fanout.rb +++ b/activesupport/lib/active_support/notifications/fanout.rb @@ -20,8 +20,8 @@ module ActiveSupport super end - def subscribe(pattern = nil, callable = nil, monotonic = false, &block) - subscriber = Subscribers.new(monotonic, pattern, callable || block) + def subscribe(pattern = nil, callable = nil, monotonic: false, &block) + subscriber = Subscribers.new(pattern, callable || block, monotonic) synchronize do if String === pattern @string_subscribers[pattern] << subscriber @@ -84,7 +84,7 @@ module ActiveSupport end module Subscribers # :nodoc: - def self.new(monotonic, pattern, listener) + def self.new(pattern, listener, monotonic) subscriber_class = monotonic ? MonotonicTimed : Timed if listener.respond_to?(:start) && listener.respond_to?(:finish) |