Class: Raven::Processor::RemoveCircularReferences

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

Constant Summary collapse

ELISION_STRING =
"(...)".freeze

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(value, visited = []) ⇒ Object


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

def process(value, visited = [])
  return ELISION_STRING if visited.include?(value.__id__)

  visited << value.__id__ if value.is_a?(Array) || value.is_a?(Hash)

  case value
  when Hash
    !value.frozen? ? value.merge!(value) { |_, v| process v, visited } : value.merge(value) { |_, v| process v, visited }
  when Array
    !value.frozen? ? value.map! { |v| process v, visited } : value.map { |v| process v, visited }
  else
    value
  end
end