# class Raven::Processor::SanitizeData

### Constants

CREDIT_CARD_RE
DEFAULT_FIELDS
INT_MASK
REGEX_SPECIAL_CHARACTERS
STRING_MASK

### Attributes

sanitize_credit_cards[RW]
sanitize_fields[RW]

### Public Class Methods

new(client) click to toggle source
Calls superclass method Raven::Processor.new

    # File lib/raven/processor/sanitizedata.rb, line 12
    def initialize(client)
      super
      self.sanitize_fields = client.configuration.sanitize_fields
      self.sanitize_credit_cards = client.configuration.sanitize_credit_cards
    end

### Public Instance Methods

process(value) click to toggle source

    # File lib/raven/processor/sanitizedata.rb, line 18
    def process(value)
      value.each_with_object(value) { |(k,v), memo| memo[k] = sanitize(k,v) }
    end

sanitize(k,v) click to toggle source

    # File lib/raven/processor/sanitizedata.rb, line 22
    def sanitize(k,v)
      if v.is_a?(Hash)
        process(v)
      elsif v.is_a?(Array)
        v.map{|a| sanitize(k, a)}
      elsif k.to_s == 'query_string'
        sanitize_query_string(v)
      elsif v.is_a?(Integer) && matches_regexes?(k,v)
        INT_MASK
      elsif v.is_a?(String)
        if fields_re.match(v.to_s) && (json = parse_json_or_nil(v))
          #if this string is actually a json obj, convert and sanitize
          json.is_a?(Hash) ? process(json).to_json : v
        elsif matches_regexes?(k,v)
          STRING_MASK
        else
          v
        end
      else
        v
      end
    end