Class: Treefell::Filters::EnvFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/treefell/filters/env_filter.rb

Constant Summary collapse

ENV_VAR_KEY =
'DEBUG'
ENV_VAR_LOOKUP =
-> { ENV[ENV_VAR_KEY] }
WILDCARD =
'*'

Instance Method Summary collapse

Constructor Details

#initialize(value: ENV_VAR_LOOKUP) ⇒ EnvFilter



8
9
10
# File 'lib/treefell/filters/env_filter.rb', line 8

def initialize(value: ENV_VAR_LOOKUP)
  @value_proc = value
end

Instance Method Details

#==(other) ⇒ Object



18
19
20
21
# File 'lib/treefell/filters/env_filter.rb', line 18

def ==(other)
  other.is_a?(self.class) &&
    other.instance_variable_get(:@value_proc) == @value_proc
end

#call(namespace, message) ⇒ Object



12
13
14
15
16
# File 'lib/treefell/filters/env_filter.rb', line 12

def call(namespace, message)
  @value = @value_proc.call
  is_mentioned?(namespace)
  is_mentioned?(namespace) || is_mentioned?(WILDCARD)
end