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, kwargs) ⇒ Object



176
177
178
# File 'lib/bootsnap/compile_cache/yaml.rb', line 176

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

#input_to_storage(contents, _) ⇒ Object



153
154
155
156
157
158
159
160
161
162
163
# File 'lib/bootsnap/compile_cache/yaml.rb', line 153

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



165
166
167
168
169
170
171
172
173
174
# File 'lib/bootsnap/compile_cache/yaml.rb', line 165

def storage_to_output(data, kwargs)
  if kwargs&.key?(:symbolize_names)
    kwargs[:symbolize_keys] = kwargs.delete(:symbolize_names)
  end

  unpacker = CompileCache::YAML.msgpack_factory.unpacker(kwargs)
  unpacker.feed(data)
  _safe_loaded = unpacker.unpack
  unpacker.unpack
end