Sha256: dc475618c385ef42f93b042ac7dc868cb2d30a5ef676e37bb0a86357a20c7114

Contents?: true

Size: 694 Bytes

Versions: 1

Compression:

Stored size: 694 Bytes

Contents

module Rollbar
  module JSON
    extend self

    attr_accessor :backend_name
    attr_accessor :dump_method
    attr_accessor :load_method

    def load_oj
      require 'oj'

      options = { :mode=> :compat,
                  :use_to_json => false,
                  :symbol_keys => false,
                  :circular => false
                }

      self.dump_method = proc { |obj| Oj.dump(obj, options) }
      self.load_method = proc { |obj| Oj.load(obj, options) }
      self.backend_name = :oj

      true
    end

    def dump(object)
      dump_method.call(object)
    end

    def load(string)
      load_method.call(string)
    end

    def setup
      load_oj
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rollbar-2.3.0 lib/rollbar/json.rb