Added AR:B#dup method for duplicationg object without frozen attributes [#2859 state:resolved]

Signed-off-by: Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>
This commit is contained in:
Yehuda Katz + Carl Lerche 2009-07-01 12:16:35 -07:00
parent 882dd4e605
commit 16dc139caa
2 changed files with 11 additions and 0 deletions

@ -2870,6 +2870,13 @@ def frozen?
@attributes.frozen?
end
# Returns duplicated record with unfreezed attributes.
def dup
obj = super
obj.instance_variable_set('@attributes', instance_variable_get('@attributes').dup)
obj
end
# Returns +true+ if the record is read only. Records loaded through joins with piggy-back
# attributes will be marked as read only since they cannot be saved.
def readonly?

@ -2116,4 +2116,8 @@ def test_create_with_custom_timestamps
assert_equal custom_datetime, parrot[attribute]
end
end
def test_dup
assert !Minimalistic.new.freeze.dup.frozen?
end
end