class Treefell::Filters::EnvFilter

Constants

NAMESPACE_ENV_VAR_KEY
NAMESPACE_ENV_VAR_LOOKUP
WILDCARD

Public Class Methods

new(value: NAMESPACE_ENV_VAR_LOOKUP) click to toggle source
# File lib/treefell/filters/env_filter.rb, line 8
def initialize(value: NAMESPACE_ENV_VAR_LOOKUP)
  @value_proc = value
end

Public Instance Methods

==(other) click to toggle source
# 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) click to toggle source
# 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

Private Instance Methods

is_mentioned?(str) click to toggle source
# File lib/treefell/filters/env_filter.rb, line 25
def is_mentioned?(str)
  @value.to_s.split(/\s*,\s*/).include?(str)
end