Class: Xail::FilterRegistry
- Inherits:
-
Object
- Object
- Xail::FilterRegistry
- Defined in:
- lib/xail/filter.rb
Class Method Summary collapse
- .filters ⇒ Object
-
.find_filters ⇒ Object
naively assume all filters are defined in this file, or at least loaded before this executes.
- .get_filter(key) ⇒ Object
Class Method Details
.filters ⇒ Object
13 14 15 |
# File 'lib/xail/filter.rb', line 13 def self.filters @@filters ||= FilterRegistry.find_filters end |
.find_filters ⇒ Object
naively assume all filters are defined in this file, or at least loaded before this executes
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/xail/filter.rb', line 20 def self.find_filters filters = Hash.new ObjectSpace.each_object(Class).select { |classObject| classObject < AbstractFilter and not classObject.name.downcase.include? "abstract" }.map { |filterclass| filtername = filterclass.name.split('::').last.gsub(/filter/i, '') filters[filtername.downcase] = filterclass } filters end |
.get_filter(key) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/xail/filter.rb', line 33 def self.get_filter(key) name = key.to_s @@filters ||= FilterRegistry.filters if @@filters.has_key? name return @@filters[name] end # if we couldn't find the filter, rebuild the list and try # again @@filters = FilterRegistry.find_filters if @@filters.has_key? name return @@filters[name] else raise UnknownFilter.new(name) end end |