Module: Bootsnap::CompileCache::YAML::Psych4::UnsafeLoad
Instance Method Summary collapse
- #input_to_output(data, _path, kwargs) ⇒ Object
- #input_to_storage(contents, _) ⇒ Object
- #storage_to_output(data, kwargs) ⇒ Object
Instance Method Details
#input_to_output(data, _path, kwargs) ⇒ Object
179 180 181 |
# File 'lib/bootsnap/compile_cache/yaml.rb', line 179 def input_to_output(data, _path, kwargs) ::YAML.unsafe_load(data, **(kwargs || {})) end |
#input_to_storage(contents, _) ⇒ Object
154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/bootsnap/compile_cache/yaml.rb', line 154 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
166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/bootsnap/compile_cache/yaml.rb', line 166 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 result = unpacker.unpack data.clear result end |