Class: Serf::Util::RegexpMatcher
- Inherits:
-
Object
- Object
- Serf::Util::RegexpMatcher
- Defined in:
- lib/serf/util/regexp_matcher.rb
Overview
A matcher that does a regexp match on a specific field in the given Env. By default, we use this to do regexp matching on message kinds for routing.
Instance Attribute Summary collapse
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#regexp ⇒ Object
readonly
Returns the value of attribute regexp.
Class Method Summary collapse
Instance Method Summary collapse
- #===(env) ⇒ Object
-
#initialize(regexp, options = {}) ⇒ RegexpMatcher
constructor
A new instance of RegexpMatcher.
Constructor Details
#initialize(regexp, options = {}) ⇒ RegexpMatcher
Returns a new instance of RegexpMatcher.
13 14 15 16 |
# File 'lib/serf/util/regexp_matcher.rb', line 13 def initialize(regexp, ={}) @regexp = regexp @field = .fetch(:field) { :kind } end |
Instance Attribute Details
#field ⇒ Object (readonly)
Returns the value of attribute field.
11 12 13 |
# File 'lib/serf/util/regexp_matcher.rb', line 11 def field @field end |
#regexp ⇒ Object (readonly)
Returns the value of attribute regexp.
10 11 12 |
# File 'lib/serf/util/regexp_matcher.rb', line 10 def regexp @regexp end |
Class Method Details
.build(regexp) ⇒ Object
22 23 24 |
# File 'lib/serf/util/regexp_matcher.rb', line 22 def self.build(regexp) return self.new regexp end |
Instance Method Details
#===(env) ⇒ Object
18 19 20 |
# File 'lib/serf/util/regexp_matcher.rb', line 18 def ===(env) return @regexp === env[@field] end |