Class: RightSupport::Notifier::Blacklister::Simple

Inherits:
Base
  • Object
show all
Defined in:
lib/right_support/notifiers/blacklisters/simple.rb

Overview

implements a simple blacklister that matches a literal top-level key.

Instance Attribute Summary

Attributes inherited from Base

#replacement_value

Instance Method Summary collapse

Constructor Details

#initialize(keys, options = {}) ⇒ Simple

Returns a new instance of Simple.

Parameters:

  • keys (Array|String)

    to blacklist

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :replacement_value (Object)

    of any kind including nil. default=‘HIDDEN’.



32
33
34
35
# File 'lib/right_support/notifiers/blacklisters/simple.rb', line 32

def initialize(keys, options = {})
  super(options)
  @keys = ::Set.new(Array(keys).map(&:to_s))
end

Instance Method Details

#filter(data) ⇒ Object

implements RightSupport::Notifier::Blacklister::Base#filter



38
39
40
41
42
43
44
45
# File 'lib/right_support/notifiers/blacklisters/simple.rb', line 38

def filter(data)
  @keys.each do |key|
    if data.has_key?(key)
      data[key] = replacement_value
    end
  end
  true
end