class Dump::Env::Filter

Filter strings by simple pattern:

'a,b,c' will pass only 'a', 'b' and 'c'
'-a,b,c' will pass everything except 'a', 'b' and 'c'

Attributes

invert[R]
transparent[R]
values[R]

Public Class Methods

new(string, splitter = nil) click to toggle source
# File lib/dump/env/filter.rb, line 11
def initialize(string, splitter = nil)
  if string
    string = string.dup
    @invert = !!string.sub!(/^-/, '')
    @values = string.split(splitter || ',').map(&:strip).map(&:downcase).uniq.select(&:present?)
  else
    @transparent = true
  end
end

Public Instance Methods

custom_pass?(&block) click to toggle source
# File lib/dump/env/filter.rb, line 25
def custom_pass?(&block)
  transparent || (invert ^ values.any?(&block))
end
pass?(value) click to toggle source
# File lib/dump/env/filter.rb, line 21
def pass?(value)
  transparent || (invert ^ values.include?(value.to_s.downcase))
end