Skip to content

Commit

Permalink
dup values so that in-place edits to model values do not update the s…
Browse files Browse the repository at this point in the history
…tub values
  • Loading branch information
technoweenie committed Jul 6, 2008
1 parent 847b4ec commit 7a383da
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/model_stubbing/stub.rb
Expand Up @@ -137,7 +137,11 @@ def instantiate(this_record_key, attributes)
record.send("#{key}=", records)
record.new_record = nr
else
record.send("#{key}=", value)
duped_value = case value
when TrueClass, FalseClass, Fixnum, Float, NilClass, Symbol then value
else value.dup
end
record.send("#{key}=", duped_value)
end
end
record
Expand Down

0 comments on commit 7a383da

Please sign in to comment.