Class: CodelessCode::Filters::Headers::Base
- Inherits:
-
Object
- Object
- CodelessCode::Filters::Headers::Base
- Defined in:
- lib/codeless_code/filters/headers/base.rb
Overview
Abstract base class for all generic filters that test a fable’s headers.
Instance Method Summary collapse
- #call(fable) ⇒ Object
- #enabled? ⇒ Boolean
-
#initialize(key, exclude, *tests) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(key, exclude, *tests) ⇒ Base
24 25 26 27 28 |
# File 'lib/codeless_code/filters/headers/base.rb', line 24 def initialize(key, exclude, *tests) @key = key @exclude = exclude @tests ||= tests.select(&:first).freeze end |
Instance Method Details
#call(fable) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/codeless_code/filters/headers/base.rb', line 34 def call(fable) if fable.header?(@key) @tests.any? ? test(parse(fable[@key])) : !@exclude else @exclude end end |
#enabled? ⇒ Boolean
30 31 32 |
# File 'lib/codeless_code/filters/headers/base.rb', line 30 def enabled? @tests.any? || @exclude end |