Module: Bootsnap::CompileCache::YAML::Psych4::UnsafeLoad

Extended by:
UnsafeLoad
Included in:
UnsafeLoad
Defined in:
lib/bootsnap/compile_cache/yaml.rb

Instance Method Summary collapse

Instance Method Details

#input_to_output(data, _path, kwargs) ⇒ Object



227
228
229
# File 'lib/bootsnap/compile_cache/yaml.rb', line 227

def input_to_output(data, _path, kwargs)
  ::YAML.unsafe_load(data, **(kwargs || {}))
end

#input_to_storage(contents, _) ⇒ Object



204
205
206
207
208
209
210
211
212
213
214
# File 'lib/bootsnap/compile_cache/yaml.rb', line 204

def input_to_storage(contents, _)
  obj = ::YAML.unsafe_load(contents)
  packer = CompileCache::YAML.msgpack_factory.packer
  packer.pack(false) # not safe loaded
  begin
    packer.pack(obj)
  rescue NoMethodError, RangeError
    return UNCOMPILABLE # The object included things that we can't serialize
  end
  packer.to_s
end

#storage_to_output(data, kwargs) ⇒ Object



216
217
218
219
220
221
222
223
224
225
# File 'lib/bootsnap/compile_cache/yaml.rb', line 216

def storage_to_output(data, kwargs)
  unpacker = CompileCache::YAML.msgpack_factory.unpacker(
    CompileCache::YAML.msgpack_unpacker_options(kwargs),
  )
  unpacker.feed(data)
  _safe_loaded = unpacker.unpack
  result = unpacker.unpack
  data.clear
  result
end