Class: Raven::Processor::RemoveCircularReferences

Inherits:
Raven::Processor show all
Defined in:
lib/raven/processor/removecircularreferences.rb

Constant Summary

Constants inherited from Raven::Processor

INT_MASK, REGEX_SPECIAL_CHARACTERS, STRING_MASK

Instance Method Summary collapse

Methods inherited from Raven::Processor

#initialize

Constructor Details

This class inherits a constructor from Raven::Processor

Instance Method Details

#process(v, visited = []) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/raven/processor/removecircularreferences.rb', line 3

def process(v, visited = [])
  return "(...)" if visited.include?(v.__id__)
  visited += [v.__id__]
  if v.is_a?(Hash)
    v.each_with_object({}) { |(k, v_), memo| memo[k] = process(v_, visited) }
  elsif v.is_a?(Array)
    v.map { |v_| process(v_, visited) }
  else
    v
  end
end