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.
29 30 31 |
# File 'lib/codeless_code/filters/composite.rb', line 29 def initialize(*filters) @filters = filters.flatten end |
Instance Attribute Details
#filters ⇒ Object (readonly)
Returns the value of attribute filters.
26 27 28 |
# File 'lib/codeless_code/filters/composite.rb', line 26 def filters @filters end |
Instance Method Details
#call(fable) ⇒ Object
37 38 39 |
# File 'lib/codeless_code/filters/composite.rb', line 37 def call(fable) select(&:enabled?).all? { |filter| filter.call(fable) } end |
#enabled? ⇒ Boolean
33 34 35 |
# File 'lib/codeless_code/filters/composite.rb', line 33 def enabled? any?(&:enabled?) end |