Class: CodelessCode::Filters::Composite

Inherits:
Object
  • Object
show all
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

FromOptions

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#filtersObject (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

Returns:

  • (Boolean)


35
36
37
# File 'lib/codeless_code/filters/composite.rb', line 35

def enabled?
  any?(&:enabled?)
end