diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | lib/delegate.rb | 14 |
2 files changed, 9 insertions, 11 deletions
@@ -1,3 +1,9 @@ +Fri Jan 29 01:42:24 2010 Yukihiro Matsumoto <[email protected]> + + * 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 <[email protected]> * 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. |