Sha256: 9bb0ce03c079a62222543886286b918d821b9aba1730ecc5206aca71f1398137

Contents?: true

Size: 912 Bytes

Versions: 2

Compression:

Stored size: 912 Bytes

Contents

module DataCleansing
  include SemanticLogger::Loggable

  # Global Data Cleansers
  @@global_cleaners     = Concurrent::Hash.new
  @@masked_attributes   = Concurrent::Array.new

  # Register a new cleaner
  # Replaces any existing cleaner with the same name
  def self.register_cleaner(name, cleaner = nil, &block)
    raise "Must supply a Proc with the cleaner" unless block || cleaner
    @@global_cleaners[name.to_sym] = cleaner || block
  end

  # Returns the cleaner matching the supplied cleaner name
  def self.cleaner(cleaner_name)
    @@global_cleaners[cleaner_name.to_sym]
  end

  # Register Attributes to be masked out in any log output
  def self.register_masked_attributes(*attributes)
    attributes.each {|attr| @@masked_attributes << attr.to_sym }
  end

  # Returns the Global list of attributes to mask in any log output
  def self.masked_attributes
    @@masked_attributes.freeze
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
data_cleansing-0.9.0 lib/data_cleansing/data_cleansing.rb
data_cleansing-0.8.0 lib/data_cleansing/data_cleansing.rb