Class: RightSupport::Notifier::Blacklister::RegularExpression
- Defined in:
- lib/right_support/notifiers/blacklisters/regular_expression.rb
Overview
implements a blacklister that matches key paths by regular expression.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#delimiter ⇒ Object
readonly
Returns the value of attribute delimiter.
Attributes inherited from Base
Class Method Summary collapse
- .normalize_regular_expressions(regular_expressions) ⇒ Object
-
.to_regexp(re) ⇒ Regexp
compiles a regular expression, if necessary.
Instance Method Summary collapse
-
#filter(data) ⇒ Object
implements RightSupport::Notifier::Blacklister::Base#filter.
-
#initialize(regular_expressions, options = {}) ⇒ RegularExpression
constructor
A new instance of RegularExpression.
Constructor Details
#initialize(regular_expressions, options = {}) ⇒ RegularExpression
Returns a new instance of RegularExpression.
36 37 38 39 40 41 42 43 |
# File 'lib/right_support/notifiers/blacklisters/regular_expression.rb', line 36 def initialize(regular_expressions, = {}) super() = { delimiter: '/' }.merge() @delimiter = [:delimiter].to_s @regular_expressions = ::RightSupport::Notifier::Blacklister::RegularExpression.normalize_regular_expressions(regular_expressions) end |
Instance Attribute Details
#delimiter ⇒ Object (readonly)
Returns the value of attribute delimiter.
28 29 30 |
# File 'lib/right_support/notifiers/blacklisters/regular_expression.rb', line 28 def delimiter @delimiter end |
Class Method Details
.normalize_regular_expressions(regular_expressions) ⇒ Object
51 52 53 |
# File 'lib/right_support/notifiers/blacklisters/regular_expression.rb', line 51 def self.normalize_regular_expressions(regular_expressions) ::Set.new(Array(regular_expressions).map(&self.method(:to_regexp))) end |
.to_regexp(re) ⇒ Regexp
compiles a regular expression, if necessary.
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/right_support/notifiers/blacklisters/regular_expression.rb', line 60 def self.to_regexp(re) case re when ::String ::Regexp.compile(re) when ::Regexp re else fail "Unexpected type: #{re.class.name}" end end |
Instance Method Details
#filter(data) ⇒ Object
implements RightSupport::Notifier::Blacklister::Base#filter
46 47 48 |
# File 'lib/right_support/notifiers/blacklisters/regular_expression.rb', line 46 def filter(data) recursive_filter(data, nil) end |