Module: ActiveSupport::Notifications::Fanout::Subscribers

Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/notifications/fanout.rb

Overview

:nodoc:

Defined Under Namespace

Classes: EventObject, Evented, Matcher, MonotonicTimed, Timed

Class Method Summary collapse

Class Method Details

.new(pattern, listener, monotonic) ⇒ Object



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/notifications/fanout.rb', line 126

def self.new(pattern, listener, monotonic)
  subscriber_class = monotonic ? MonotonicTimed : Timed

  if listener.respond_to?(:start) && listener.respond_to?(:finish)
    subscriber_class = Evented
  else
    # Doing this to detect a single argument block or callable
    # like `proc { |x| }` vs `proc { |*x| }`, `proc { |**x| }`,
    # or `proc { |x, **y| }`
    procish = listener.respond_to?(:parameters) ? listener : listener.method(:call)

    if procish.arity == 1 && procish.parameters.length == 1
      subscriber_class = EventObject
    end
  end

  subscriber_class.new(pattern, listener)
end