Sha256: dd095418ecd80d213088a207f590c1cde62f605e7a06db2e44ecb29ebee6ab21

Contents?: true

Size: 713 Bytes

Versions: 1

Compression:

Stored size: 713 Bytes

Contents

require 'hedgelog/scrub_replacement'

class Hedgelog
  class Scrubber
    def initialize(replacements = nil)
      @replacements = [ScrubReplacement.new('password', '**********')]
      unless replacements.nil?
        replacements.each do |x|
          if x.instance_of?(ScrubReplacement)
            @replacements << x
          else
            @replacements << ScrubReplacement.new(x,'**********')
          end
        end
      end
    end

    def scrub(data)
      # Need to Marshal.dump/Marshal.load to deep copy the input so that scrubbing doesn't change global state
      d = Marshal.load(Marshal.dump(data))
      @replacements.each do |r|
        r.scrub_hash(d)
      end
      d
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hedgelog-0.2.0 lib/hedgelog/scrubber.rb