instance method
subscribe
Ruby on Rails 7.2.3
Since v3.0.20Signature
subscribe(pattern = nil, callable = nil, monotonic: false, &block)
No documentation comment.
Parameters
-
patternopt = nil -
callableopt = nil -
monotonickey = false -
blockblock
Source
# File activesupport/lib/active_support/notifications/fanout.rb, line 65
def subscribe(pattern = nil, callable = nil, monotonic: false, &block)
subscriber = Subscribers.new(pattern, callable || block, monotonic)
@mutex.synchronize do
case pattern
when String
@string_subscribers[pattern] << subscriber
clear_cache(pattern)
when NilClass, Regexp
@other_subscribers << subscriber
clear_cache
else
raise ArgumentError, "pattern must be specified as a String, Regexp or empty"
end
end
subscriber
end
Defined in activesupport/lib/active_support/notifications/fanout.rb line 65
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::Notifications::Fanout