Method: ROF::Filters.for

Defined in:
lib/rof/filters.rb

.for(filter_name, options = {}) ⇒ ROF::Filter

Parameters:

  • filter_name (String)
    • the named filter you want to instantiate

  • options (Hash) (defaults to: {})
    • a hash (with symbol keys) that is used for configuring the instantiating of the filter

Returns:

Raises:

  • ROF::Filters::UnknownFilterError if the given filter name is not registered

See Also:

  • /spec/support/an_rof_filter./spec/support/an_rof_filter.rb
  • ROF::Filter


30
31
32
33
34
35
36
37
# File 'lib/rof/filters.rb', line 30

def self.for(filter_name, options = {})
  begin
    filter = AVAILABLE_FILTERS.fetch(filter_name)
  rescue KeyError
    raise UnknownFilterError.new(filter_name, AVAILABLE_FILTERS.keys)
  end
  filter.new(options)
end