Module: Bootsnap::CompileCache::YAML::Psych4::SafeLoad
Instance Method Summary collapse
- #input_to_output(data, kwargs) ⇒ Object
- #input_to_storage(contents, _) ⇒ Object
- #storage_to_output(data, kwargs) ⇒ Object
Instance Method Details
#input_to_output(data, kwargs) ⇒ Object
218 219 220 |
# File 'lib/bootsnap/compile_cache/yaml.rb', line 218 def input_to_output(data, kwargs) ::YAML.load(data, **(kwargs || {})) end |
#input_to_storage(contents, _) ⇒ Object
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/bootsnap/compile_cache/yaml.rb', line 186 def input_to_storage(contents, _) obj = begin CompileCache::YAML.strict_load(contents) rescue Psych::DisallowedClass, Psych::BadAlias, Uncompilable return UNCOMPILABLE end packer = CompileCache::YAML.msgpack_factory.packer packer.pack(true) # safe loaded begin packer.pack(obj) rescue NoMethodError, RangeError return UNCOMPILABLE end packer.to_s end |
#storage_to_output(data, kwargs) ⇒ Object
203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/bootsnap/compile_cache/yaml.rb', line 203 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 if safe_loaded unpacker.unpack else UNCOMPILABLE end end |