From 4f7b435c955792af780fe9e94f98d3dde839e056 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Mon, 23 Sep 2019 16:03:15 -0700 Subject: Support obj.clone(freeze: true) for freezing clone This freezes the clone even if the receiver is not frozen. It is only for consistency with freeze: false not freezing the clone even if the receiver is frozen. Because Object#clone is now partially implemented in Ruby and not fully implemented in C, freeze: nil must be supported to provide the default behavior of only freezing the clone if the receiver is frozen. This requires modifying delegate and set, to set freeze: nil instead of freeze: true as the keyword parameter for initialize_clone. Those are the two libraries in stdlib that override initialize_clone. Implements [Feature #16175] --- lib/delegate.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/delegate.rb') diff --git a/lib/delegate.rb b/lib/delegate.rb index e3b3488c16..c540c2ec77 100644 --- a/lib/delegate.rb +++ b/lib/delegate.rb @@ -218,7 +218,7 @@ class Delegator < BasicObject end end - def initialize_clone(obj, freeze: true) # :nodoc: + def initialize_clone(obj, freeze: nil) # :nodoc: self.__setobj__(obj.__getobj__.clone(freeze: freeze)) end def initialize_dup(obj) # :nodoc: -- cgit v1.2.3