Class: RShade::Filter::VariableFilter

Inherits:
AbstractFilter show all
Defined in:
lib/rshade/filter/variable_filter.rb

Constant Summary collapse

NAME =
:variable_filter

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractFilter

#config

Constructor Details

#initializeVariableFilter

Returns a new instance of VariableFilter.



10
11
12
13
# File 'lib/rshade/filter/variable_filter.rb', line 10

def initialize
  super
  @matchers = []
end

Instance Attribute Details

#matchersObject (readonly)

Returns the value of attribute matchers.



6
7
8
# File 'lib/rshade/filter/variable_filter.rb', line 6

def matchers
  @matchers
end

Instance Method Details

#call(event) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/rshade/filter/variable_filter.rb', line 23

def call(event)
  matchers.each do |match|
    event.vars.each do |name, hash|
      return true if match.call(name, hash[:value])
    end
  end
  false
end

#config_call(&block) ⇒ Object



32
33
34
# File 'lib/rshade/filter/variable_filter.rb', line 32

def config_call(&block)
  matchers << block
end

#nameObject



15
16
17
# File 'lib/rshade/filter/variable_filter.rb', line 15

def name
  :variable_filter
end

#priorityObject



19
20
21
# File 'lib/rshade/filter/variable_filter.rb', line 19

def priority
  2
end