Module: CrashHook::Serializer

Included in:
Payload
Defined in:
lib/crash_hook/serializer.rb

Instance Method Summary collapse

Instance Method Details

#clean_non_serializable_data(data) ⇒ Object



11
12
13
14
15
16
# File 'lib/crash_hook/serializer.rb', line 11

def clean_non_serializable_data(data)
  data.select{|k,v| serializable?(v) }.inject({}) do |h, pair|
    h[pair.first] = pair.last.is_a?(Hash) ? clean_non_serializable_data(pair.last) : pair.last
    h
  end
end

#serializable?(value) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
6
7
8
9
# File 'lib/crash_hook/serializer.rb', line 3

def serializable?(value)
  value.is_a?(Fixnum) ||
  value.is_a?(Array) ||
  value.is_a?(String) ||
  value.is_a?(Hash) ||
  value.is_a?(Bignum)
end