Class: Sidekiq::Antidote::ClassQualifier

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/sidekiq/antidote/class_qualifier.rb

Overview

Job display class pattern matcher. Some job classes may be represented by class and metehod name (e.g., ‘OnboardingMailer#welcome`) which is handled by this qualifier.

## Pattern Special Characters

  • ‘*` matches any number of alpha-numeric characters and underscores. Examples: `Foo`, `FooBar`, `method_name`

  • ‘**` matches any number of components. Examples: `Foo`, `Foo::Bar`, `Foo::Bar#method_name`

  • ‘A,B,C` matches literal `A`, `B`, or `C`.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pattern) ⇒ ClassQualifier

Returns a new instance of ClassQualifier.

Parameters:

Raises:

  • (ArgumentError)


40
41
42
43
44
45
46
47
# File 'lib/sidekiq/antidote/class_qualifier.rb', line 40

def initialize(pattern)
  @pattern = pattern.to_s.strip.freeze
  raise ArgumentError, "blank pattern" if @pattern.empty?

  @regexp = build_regexp(@pattern)

  freeze
end

Instance Attribute Details

#patternString (readonly) Also known as: to_s

Returns:

  • (String)


33
34
35
# File 'lib/sidekiq/antidote/class_qualifier.rb', line 33

def pattern
  @pattern
end

#regexpRegexp (readonly)

Returns:

  • (Regexp)


37
38
39
# File 'lib/sidekiq/antidote/class_qualifier.rb', line 37

def regexp
  @regexp
end

Instance Method Details

#eql?(other) ⇒ Boolean Also known as: ==

Parameters:

  • other (Object)

Returns:

  • (Boolean)


57
58
59
# File 'lib/sidekiq/antidote/class_qualifier.rb', line 57

def eql?(other)
  self.class == other.class && pattern == other.pattern
end

#match?(job_class) ⇒ Boolean

Parameters:

  • job_class (String, Class)

Returns:

  • (Boolean)


51
52
53
# File 'lib/sidekiq/antidote/class_qualifier.rb', line 51

def match?(job_class)
  regexp.match?(job_class.to_s)
end