Sha256: 42d1d2b9489987c8bc009f92d14ca2915674101183f12e9de11d16da6fbb23de
Contents?: true
Size: 642 Bytes
Versions: 17
Compression:
Stored size: 642 Bytes
Contents
module JSONAPI class CompiledJson def self.compile(h) new(JSON.generate(h), h) end def self.of(obj) case obj when NilClass then nil when CompiledJson then obj when String then CompiledJson.new(obj) when Hash then CompiledJson.compile(obj) else raise "Can't figure out how to turn #{obj.inspect} into CompiledJson" end end def initialize(json, h = nil) @json = json @h = h end def to_json(*args) @json end def to_s @json end def to_h @h ||= JSON.parse(@json) end undef_method :as_json end end
Version data entries
17 entries across 17 versions & 1 rubygems