diff options
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) |