Sha256: e77a22f7036d13979e94c1cb7925677c78ffe66b99987e06dc6dfc9016a43cb7

Contents?: true

Size: 882 Bytes

Versions: 12

Compression:

Stored size: 882 Bytes

Contents

require 'singleton'
require 'multi_json/options'

module MultiJson
  class Adapter
    extend Options
    include Singleton
    class << self

      def defaults(action, value)
        metaclass = class << self; self; end

        metaclass.instance_eval do
          define_method("default_#{action}_options"){ value }
        end
      end

      def load(string, options={})
        raise self::ParseError if blank?(string)
        instance.load(string, load_options(options).merge(MultiJson.load_options(options)).merge!(options))
      end

      def dump(object, options={})
        instance.dump(object, dump_options(options).merge(MultiJson.dump_options(options)).merge!(options))
      end

    private

      def blank?(input)
        input.nil? || /\A\s*\z/ === input
      rescue ArgumentError # invalid byte sequence in UTF-8
        false
      end

    end
  end
end

Version data entries

12 entries across 5 versions & 4 rubygems

Version Path
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/multi_json-1.10.1/lib/multi_json/adapter.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/multi_json-1.10.1/lib/multi_json/adapter.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/multi_json-1.10.1/lib/multi_json/adapter.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/multi_json-1.10.1/lib/multi_json/adapter.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.8/gems/multi_json-1.10.1/lib/multi_json/adapter.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.9.1/gems/multi_json-1.10.1/lib/multi_json/adapter.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/multi_json-1.10.1/lib/multi_json/adapter.rb
apl-library-0.0.90 vendor/bundle/ruby/1.8/gems/multi_json-1.10.1/lib/multi_json/adapter.rb
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/multi_json-1.10.1/lib/multi_json/adapter.rb
asana2flowdock-1.0.0 vendor/bundle/ruby/1.9.1/gems/multi_json-1.10.1/lib/multi_json/adapter.rb
multi_json-1.10.1 lib/multi_json/adapter.rb
multi_json-1.10.0 lib/multi_json/adapter.rb