Class: MessageFilter::Filter::Filters

Inherits:
Object
  • Object
show all
Defined in:
lib/message_filter/filter_methods.rb

Overview

filter instances

Instance Method Summary collapse

Constructor Details

#initializeFilters

Returns a new instance of Filters.



30
31
32
# File 'lib/message_filter/filter_methods.rb', line 30

def initialize
  @filters = {}
end

Instance Method Details

#add(options) ⇒ Object



34
35
36
37
# File 'lib/message_filter/filter_methods.rb', line 34

def add(options)
  new_entry = FilterEntry.new(options)
  @filters[new_entry.handler] = new_entry
end

#default_of(type) ⇒ Object



47
48
49
50
51
# File 'lib/message_filter/filter_methods.rb', line 47

def default_of(type)
  @filters.each do |_key, filter|
    return filter.handler if filter.default? type
  end
end

#filters_of(type) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/message_filter/filter_methods.rb', line 39

def filters_of(type)
  handlers = []
  @filters.each do |_key, filter|
    handlers.push filter if filter.has? type
  end
  handlers
end