summaryrefslogtreecommitdiff
path: root/marshal.rb
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2021-09-18 15:34:15 +0200
committerJean Boussier <jean.boussier@gmail.com>2021-10-05 18:34:56 +0200
commitafcbb501ac17ba2ad5370ada5fd26e8dda9a5aaa (patch)
tree7316e197ec1f1097b334ad587ee58a58d9961b3f /marshal.rb
parent279b2b5b600f0bb16f7ebb08aa4a299cf7b023a8 (diff)
marshal.c Marshal.load accepts a freeze: true option.
Fixes [Feature #18148] When set, all the loaded objects are returned as frozen. If a proc is provided, it is called with the objects already frozen.
Diffstat (limited to 'marshal.rb')
-rw-r--r--marshal.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/marshal.rb b/marshal.rb
new file mode 100644
index 0000000000..b8b5ce9e82
--- /dev/null
+++ b/marshal.rb
@@ -0,0 +1,21 @@
+module Marshal
+ # call-seq:
+ # load( source [, proc] ) -> obj
+ # restore( source [, proc] ) -> obj
+ #
+ # Returns the result of converting the serialized data in source into a
+ # Ruby object (possibly with associated subordinate objects). source
+ # may be either an instance of IO or an object that responds to
+ # to_str. If proc is specified, each object will be passed to the proc, as the object
+ # is being deserialized.
+ #
+ # Never pass untrusted data (including user supplied input) to this method.
+ # Please see the overview for further details.
+ def self.load(source, proc = nil, freeze: false)
+ Primitive.marshal_load(source, proc, freeze)
+ end
+
+ class << self
+ alias restore load
+ end
+end