mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
* object.c (rb_obj_clone): call initialize_clone hook method to
call initialize_copy. * object.c (rb_obj_dup): call initialize_dup hook. * lib/delegate.rb (Delegator#initialize_clone): use new hook to implement deep copy. [ruby-dev:40242] * lib/delegate.rb (Delegator#initialize_dup): ditto. * test/test_delegate.rb (TestDelegateClass#test_copy_frozen): add a test to ensure #clone copies frozen status. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
26051e1d06
commit
a7926befe0
4 changed files with 39 additions and 6 deletions
|
@ -205,13 +205,14 @@ class Delegator < BasicObject
|
|||
end
|
||||
|
||||
# :nodoc:
|
||||
def dup
|
||||
self.class.new(__getobj__.dup)
|
||||
def initialize_clone(obj)
|
||||
self.__setobj__(obj.__getobj__.clone)
|
||||
end
|
||||
# :nodoc:
|
||||
def clone
|
||||
self.class.new(__getobj__.clone)
|
||||
def initialize_dup(obj)
|
||||
self.__setobj__(obj.__getobj__.dup)
|
||||
end
|
||||
private :initialize_clone, :initialize_dup
|
||||
|
||||
# Freeze self and target at once.
|
||||
def freeze
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue