Module: Bugsnag::Helpers

Defined in:
lib/bugsnag/helpers.rb

Constant Summary collapse

MAX_STRING_LENGTH =
4096

Class Method Summary collapse

Class Method Details

.flatten_meta_data(overrides) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/bugsnag/helpers.rb', line 24

def self.(overrides)
  return nil unless overrides

   = overrides.delete(:meta_data)
  if .is_a?(Hash)
    overrides.merge()
  else
    overrides
  end
end

.reduce_hash_size(hash) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/bugsnag/helpers.rb', line 7

def self.reduce_hash_size(hash)
  return {} unless hash.is_a?(Hash)
  hash.inject({}) do |h, (k,v)|
    if v.is_a?(Hash)
      h[k] = reduce_hash_size(v)
    elsif v.is_a?(Array) || v.is_a?(Set)
      h[k] = v.map {|el| reduce_hash_size(el) }
    else
      val = v.to_s
      val = val.slice(0, MAX_STRING_LENGTH) + "[TRUNCATED]" if val.length > MAX_STRING_LENGTH
      h[k] = val
    end

    h
  end
end