Sha256: 551abb86727c60622db5eaa53e145d59664d85083670cab4cc6f90ea7da55019

Contents?: true

Size: 940 Bytes

Versions: 12

Compression:

Stored size: 940 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)
        string = string.read if string.respond_to?(:read)
        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 12 versions & 7 rubygems

Version Path
able-neo4j-1.0.0 vendor/bundle/jruby/1.9/gems/multi_json-1.11.2/lib/multi_json/adapter.rb
vagrant-unbundled-1.8.1.1 vendor/bundle/ruby/2.3.0/gems/multi_json-1.11.2/lib/multi_json/adapter.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/multi_json-1.11.2/lib/multi_json/adapter.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/multi_json-1.11.2/lib/multi_json/adapter.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/multi_json-1.11.2/lib/multi_json/adapter.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/multi_json-1.11.2/lib/multi_json/adapter.rb
multi_json-1.11.2 lib/multi_json/adapter.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/multi_json-1.11.1/lib/multi_json/adapter.rb
multi_json-1.11.1 lib/multi_json/adapter.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/multi_json-1.11.0/lib/multi_json/adapter.rb
shoppe-paypal-1.1.0 vendor/bundle/ruby/2.1.0/gems/multi_json-1.11.0/lib/multi_json/adapter.rb
multi_json-1.11.0 lib/multi_json/adapter.rb