Class: CodelessCode::Filters::Composite
- Inherits:
-
Object
- Object
- CodelessCode::Filters::Composite
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/codeless_code/filters/composite.rb
Overview
A filter that containers a collection of other filters. It will only match a CodelessCode::Fable if it’s matched by each contained filter.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#filters ⇒ Object
readonly
Returns the value of attribute filters.
Instance Method Summary collapse
- #call(fable) ⇒ Object
- #enabled? ⇒ Boolean
-
#initialize(*filters) ⇒ Composite
constructor
A new instance of Composite.
Constructor Details
#initialize(*filters) ⇒ Composite
Returns a new instance of Composite.
31 32 33 |
# File 'lib/codeless_code/filters/composite.rb', line 31 def initialize(*filters) @filters = filters.flatten end |
Instance Attribute Details
#filters ⇒ Object (readonly)
Returns the value of attribute filters.
28 29 30 |
# File 'lib/codeless_code/filters/composite.rb', line 28 def filters @filters end |
Instance Method Details
#call(fable) ⇒ Object
39 40 41 |
# File 'lib/codeless_code/filters/composite.rb', line 39 def call(fable) any? && select(&:enabled?).all? { |filter| filter.call(fable) } end |
#enabled? ⇒ Boolean
35 36 37 |
# File 'lib/codeless_code/filters/composite.rb', line 35 def enabled? any?(&:enabled?) end |