Class: Sidekiq::Antidote::ClassQualifier
- Inherits:
-
Object
- Object
- Sidekiq::Antidote::ClassQualifier
- 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
- #pattern ⇒ String (also: #to_s) readonly
- #regexp ⇒ Regexp readonly
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean (also: #==)
-
#initialize(pattern) ⇒ ClassQualifier
constructor
A new instance of ClassQualifier.
- #match?(job_class) ⇒ Boolean
Constructor Details
#initialize(pattern) ⇒ ClassQualifier
Returns a new instance of ClassQualifier.
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
#pattern ⇒ String (readonly) Also known as: to_s
33 34 35 |
# File 'lib/sidekiq/antidote/class_qualifier.rb', line 33 def pattern @pattern end |
#regexp ⇒ Regexp (readonly)
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: ==
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
51 52 53 |
# File 'lib/sidekiq/antidote/class_qualifier.rb', line 51 def match?(job_class) regexp.match?(job_class.to_s) end |