Class: ActiveSupport::Notifications::Fanout::Subscribers::Matcher

Inherits:
Object
  • Object
show all
Defined in:
activesupport/lib/active_support/notifications/fanout.rb

Overview

:nodoc:

Defined Under Namespace

Classes: AllMessages

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pattern) ⇒ Matcher

Returns a new instance of Matcher.


163
164
165
166
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 163

def initialize(pattern)
  @pattern = pattern
  @exclusions = Set.new
end

Instance Attribute Details

#exclusionsObject (readonly)

Returns the value of attribute exclusions.


151
152
153
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 151

def exclusions
  @exclusions
end

#patternObject (readonly)

Returns the value of attribute pattern.


151
152
153
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 151

def pattern
  @pattern
end

Class Method Details

.wrap(pattern) ⇒ Object


153
154
155
156
157
158
159
160
161
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 153

def self.wrap(pattern)
  if String === pattern
    pattern
  elsif pattern.nil?
    AllMessages.new
  else
    new(pattern)
  end
end

Instance Method Details

#===(name) ⇒ Object


172
173
174
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 172

def ===(name)
  pattern === name && !exclusions.include?(name)
end

#unsubscribe!(name) ⇒ Object


168
169
170
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 168

def unsubscribe!(name)
  exclusions << -name if pattern === name
end