/usr/lib/ruby/vendor_ruby/multi_json/adapter.rb is in ruby-multi-json 1.8.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | 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, collect_load_options(options).clone)
end
def dump(object, options={})
instance.dump(object, collect_dump_options(options).clone)
end
protected
def collect_load_options(options)
cache('load', options){ collect_options(:load_options, options).merge(options) }
end
def collect_dump_options(options)
cache('dump', options){ collect_options(:dump_options, options).merge(options) }
end
def collect_options(method, *args)
global, local = *[MultiJson, self].map{ |r| r.send(method, *args) }
local.merge(global)
end
def cache(method, options)
cache_key = [self, options].map(&:hash).join + method
MultiJson.cached_options[cache_key] ||= yield
end
private
def blank?(input)
input.nil? || /\A\s*\z/ === input
end
end
end
end
|