Sha256: 05457122f5acb03bd4b32cffce729134ddfaba7f77271391fa1ff9ed0bc49b1c
Contents?: true
Size: 776 Bytes
Versions: 18
Compression:
Stored size: 776 Bytes
Contents
module JSONAPI class CompiledJson def self.compile(h) new(JSON.generate(h), h) end def self.of(obj) # :nocov: 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 # :nocov: end def initialize(json, h = nil) @json = json @h = h end def to_json(*_args) @json end def to_s @json end # :nocov: def to_h @h ||= JSON.parse(@json) end # :nocov: def [](key) # :nocov: to_h[key] # :nocov: end undef_method :as_json end end
Version data entries
18 entries across 18 versions & 1 rubygems