diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2018-07-26 13:17:23 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2018-07-26 13:54:42 -0700 |
commit | 280670465ad54f0600dcc8f3a22ee130d623593c (patch) | |
tree | af3120f940f7cfbdd7a27fcc0cd40712debc0070 /activesupport/lib | |
parent | 4cdedb571cc842ae9883a9b9754471ae3e82f698 (diff) | |
download | rails-280670465ad54f0600dcc8f3a22ee130d623593c.tar.gz rails-280670465ad54f0600dcc8f3a22ee130d623593c.tar.bz2 rails-280670465ad54f0600dcc8f3a22ee130d623593c.zip |
fix arity check to use "parameters" for backwards compat
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/notifications/fanout.rb | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/notifications/fanout.rb b/activesupport/lib/active_support/notifications/fanout.rb index 2fd683a1de..4e4ca70942 100644 --- a/activesupport/lib/active_support/notifications/fanout.rb +++ b/activesupport/lib/active_support/notifications/fanout.rb @@ -70,13 +70,18 @@ module ActiveSupport module Subscribers # :nodoc: def self.new(pattern, listener) + subscriber_class = Timed + if listener.respond_to?(:start) && listener.respond_to?(:finish) subscriber_class = Evented else - if listener.respond_to?(:arity) && listener.arity == 1 - subscriber_class = EventObject - else - subscriber_class = Timed + # Doing all this to detect a block like `proc { |x| }` vs + # `proc { |*x| }` or `proc { |**x| }` + if listener.respond_to?(:parameters) + params = listener.parameters + if params.length == 1 && params.first.first == :opt + subscriber_class = EventObject + end end end |