1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

fix arity check to use "parameters" for backwards compat

This commit is contained in:
Aaron Patterson 2018-07-26 13:17:23 -07:00
parent 4cdedb571c
commit 280670465a
No known key found for this signature in database
GPG key ID: 953170BCB4FFAFC6

View file

@ -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