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

Inherits:
Object
  • Object
show all
Defined in:
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.



355
356
357
358
# File 'lib/active_support/notifications/fanout.rb', line 355

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

Instance Attribute Details

#exclusionsObject (readonly)

Returns the value of attribute exclusions.



343
344
345
# File 'lib/active_support/notifications/fanout.rb', line 343

def exclusions
  @exclusions
end

#patternObject (readonly)

Returns the value of attribute pattern.



343
344
345
# File 'lib/active_support/notifications/fanout.rb', line 343

def pattern
  @pattern
end

Class Method Details

.wrap(pattern) ⇒ Object



345
346
347
348
349
350
351
352
353
# File 'lib/active_support/notifications/fanout.rb', line 345

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

Instance Method Details

#===(name) ⇒ Object



364
365
366
# File 'lib/active_support/notifications/fanout.rb', line 364

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

#unsubscribe!(name) ⇒ Object



360
361
362
# File 'lib/active_support/notifications/fanout.rb', line 360

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