Class: TypeLib::FilterList

Inherits:
Array
  • Object
show all
Defined in:
lib/typelib.rb

Overview

A FilterList is a … list of filters. It includes all the methods that Array contains, plus an additional method – execute. See TypeLib::Filter.

Instance Method Summary collapse

Instance Method Details

#execute(obj) ⇒ Object

Execute the checks in this list against obj, passing in addl if any additional arguments are provided. If the check passes, the conversion is run and the chain supplied to the constructor is followed. If no checks pass, the original item is returned.



26
27
28
29
# File 'lib/typelib.rb', line 26

def execute(obj)
  f = find { |filter| filter.check(obj) }
  f ? f.convert(obj) : obj
end