Class: Watobo::Interceptor::Filter
- Inherits:
-
Object
- Object
- Watobo::Interceptor::Filter
- Defined in:
- lib/watobo/core/intercept_filter.rb
Direct Known Subclasses
FlagFilter, HttpParmsFilter, MethodFilter, StatusFilter, UrlFilter
Instance Attribute Summary collapse
-
#flags ⇒ Object
readonly
Returns the value of attribute flags.
-
#match_type ⇒ Object
readonly
Returns the value of attribute match_type.
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
Instance Method Summary collapse
-
#initialize(pattern, prefs = {}) ⇒ Filter
constructor
A new instance of Filter.
- #match?(item, flags) ⇒ Boolean
- #name ⇒ Object
- #negate=(state) ⇒ Object
- #negated? ⇒ Boolean
Constructor Details
#initialize(pattern, prefs = {}) ⇒ Filter
Returns a new instance of Filter.
46 47 48 49 50 51 |
# File 'lib/watobo/core/intercept_filter.rb', line 46 def initialize(pattern, prefs={}) @flags = prefs.has_key?(:flags) ? prefs[:flags] : [] @match_type = prefs.has_key?(:match_type) ? prefs[:match_type] : :match @negate = ( @match_type.to_s =~ /^not/ ) @pattern = pattern end |
Instance Attribute Details
#flags ⇒ Object (readonly)
Returns the value of attribute flags.
27 28 29 |
# File 'lib/watobo/core/intercept_filter.rb', line 27 def flags @flags end |
#match_type ⇒ Object (readonly)
Returns the value of attribute match_type.
27 28 29 |
# File 'lib/watobo/core/intercept_filter.rb', line 27 def match_type @match_type end |
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
27 28 29 |
# File 'lib/watobo/core/intercept_filter.rb', line 27 def pattern @pattern end |
Instance Method Details
#match?(item, flags) ⇒ Boolean
40 41 42 43 44 |
# File 'lib/watobo/core/intercept_filter.rb', line 40 def match?(item, flags) return !check?(item, flags) if @negate == true return check?(item, flags) end |
#name ⇒ Object
28 29 30 |
# File 'lib/watobo/core/intercept_filter.rb', line 28 def name self.class.to_s.gsub(/.*::/,'') end |
#negate=(state) ⇒ Object
36 37 38 |
# File 'lib/watobo/core/intercept_filter.rb', line 36 def negate=(state) @negate = state end |
#negated? ⇒ Boolean
32 33 34 |
# File 'lib/watobo/core/intercept_filter.rb', line 32 def negated? @negate end |