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

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

Overview

:nodoc:

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pattern) ⇒ Matcher

Returns a new instance of Matcher.



123
124
125
126
# File 'lib/active_support/notifications/fanout.rb', line 123

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

Instance Attribute Details

#exclusionsObject (readonly)

Returns the value of attribute exclusions.



116
117
118
# File 'lib/active_support/notifications/fanout.rb', line 116

def exclusions
  @exclusions
end

#patternObject (readonly)

Returns the value of attribute pattern.



116
117
118
# File 'lib/active_support/notifications/fanout.rb', line 116

def pattern
  @pattern
end

Class Method Details

.wrap(pattern) ⇒ Object



118
119
120
121
# File 'lib/active_support/notifications/fanout.rb', line 118

def self.wrap(pattern)
  return pattern if String === pattern
  new(pattern)
end

Instance Method Details

#===(name) ⇒ Object



132
133
134
# File 'lib/active_support/notifications/fanout.rb', line 132

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

#unsubscribe!(name) ⇒ Object



128
129
130
# File 'lib/active_support/notifications/fanout.rb', line 128

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