Sha256: fc18ec1740d3d8ff7e586fd0b4af75eef7d7a9daf2d0869313969343eeaba9b9

Contents?: true

Size: 459 Bytes

Versions: 1

Compression:

Stored size: 459 Bytes

Contents

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

    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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
crash_hook-0.2.0 lib/crash_hook/serializer.rb