From d9e84f2327f09bbc356871c6e72e5816654cff72 Mon Sep 17 00:00:00 2001 From: matz Date: Thu, 28 Jan 2010 16:47:21 +0000 Subject: * lib/delegate.rb (Delegator#initialize_copy): use initialize_copy instead of overriding clone/dup. [ruby-dev:40221] it now always clones the target, it might cause incompatibility. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ lib/delegate.rb | 14 +++----------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index bf27476c47..058489a49b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Fri Jan 29 01:42:24 2010 Yukihiro Matsumoto + + * lib/delegate.rb (Delegator#initialize_copy): use initialize_copy + instead of overriding clone/dup. [ruby-dev:40221] + it now always clones the target, it might cause incompatibility. + Fri Jan 29 01:26:53 2010 Yukihiro Matsumoto * ext/bigdecimal/bigdecimal.c (BigDecimal_to_i): update RDoc to diff --git a/lib/delegate.rb b/lib/delegate.rb index 1516dacb15..849cad58a8 100644 --- a/lib/delegate.rb +++ b/lib/delegate.rb @@ -201,17 +201,9 @@ class Delegator end end - # Clone support for the object returned by \_\_getobj\_\_. - def clone - new = super - new.__setobj__(__getobj__.clone) - new - end - # Duplication support for the object returned by \_\_getobj\_\_. - def dup - new = super - new.__setobj__(__getobj__.dup) - new + # clone/dup support for the object returned by \_\_getobj\_\_. + def initialize_copy(other) + self.__setobj__(other.__getobj__.clone) end # Freeze self and target at once. -- cgit v1.2.3