Sha256: ac85bd1d608443aa9d8c81c601276d0e20fb570c75f52422f5ad1262d4988d26

Contents?: true

Size: 850 Bytes

Versions: 24

Compression:

Stored size: 850 Bytes

Contents

module MultiJson
  module Options

    def load_options=(options)
      @load_options = options
    end

    def dump_options=(options)
      @dump_options = options
    end

    def load_options(*args)
      defined?(@load_options) && get_options(@load_options, *args) || default_load_options
    end

    def dump_options(*args)
      defined?(@dump_options) && get_options(@dump_options, *args) || default_dump_options
    end

    def default_load_options
      @default_load_options ||= {}
    end

    def default_dump_options
      @default_dump_options ||= {}
    end

    private

    def get_options(options, *args)
      if options.respond_to?(:call) and options.arity
        options.arity == 0 ? options[] : options[*args]
      elsif Hash === options or options.respond_to?(:to_hash)
        options.to_hash
      end
    end
  end
end

Version data entries

24 entries across 17 versions & 10 rubygems

Version Path
able-neo4j-1.0.0 vendor/bundle/jruby/1.9/gems/multi_json-1.11.2/lib/multi_json/options.rb
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/multi_json-1.10.1/lib/multi_json/options.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/multi_json-1.10.1/lib/multi_json/options.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/multi_json-1.10.1/lib/multi_json/options.rb
vagrant-unbundled-1.8.1.1 vendor/bundle/ruby/2.3.0/gems/multi_json-1.11.2/lib/multi_json/options.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/multi_json-1.11.2/lib/multi_json/options.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/multi_json-1.11.2/lib/multi_json/options.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/multi_json-1.11.2/lib/multi_json/options.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/multi_json-1.11.2/lib/multi_json/options.rb
multi_json-1.11.2 lib/multi_json/options.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/multi_json-1.11.1/lib/multi_json/options.rb
multi_json-1.11.1 lib/multi_json/options.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/multi_json-1.11.0/lib/multi_json/options.rb
shoppe-paypal-1.1.0 vendor/bundle/ruby/2.1.0/gems/multi_json-1.11.0/lib/multi_json/options.rb
multi_json-1.11.0 lib/multi_json/options.rb
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/multi_json-1.10.1/lib/multi_json/options.rb
apl-library-0.0.90 vendor/bundle/ruby/1.8/gems/multi_json-1.10.1/lib/multi_json/options.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/options.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/options.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/options.rb