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:
parent
4cdedb571c
commit
280670465a
1 changed files with 9 additions and 4 deletions
|
@ -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
|
||||
# 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
|
||||
else
|
||||
subscriber_class = Timed
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue