Class: MultiJson::Adapter

Inherits:
Object
  • Object
show all
Extended by:
Options
Includes:
Singleton
Defined in:
lib/multi_json/adapter.rb

Class Method Summary collapse

Methods included from Options

default_dump_options, default_load_options, dump_options, dump_options=, load_options, load_options=

Class Method Details

.defaults(action, value) ⇒ Object


10
11
12
13
14
15
16
# File 'lib/multi_json/adapter.rb', line 10

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

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

.dump(object, options = {}) ⇒ Object


24
25
26
# File 'lib/multi_json/adapter.rb', line 24

def dump(object, options = {})
  instance.dump(object, cached_dump_options(options))
end

.load(string, options = {}) ⇒ Object


18
19
20
21
22
# File 'lib/multi_json/adapter.rb', line 18

def load(string, options = {})
  string = string.read if string.respond_to?(:read)
  fail self::ParseError if blank?(string)
  instance.load(string, cached_load_options(options))
end