Permalink
Browse files

detach the BitmaskAttributes::Proxy instance variable on dup

Before modifying the bitmask of a dupped object would also modify the original
object. This commit resets the proxy before dupping it which fixes this issue.
  • Loading branch information...
1 parent 1ab3131 commit b27a3431c846ee9e80c53e8b1a92eeb6ef694ead @aduffeck aduffeck committed Dec 1, 2011
Showing with 10 additions and 0 deletions.
  1. +10 −0 lib/bitmask_attributes/definition.rb
View
10 lib/bitmask_attributes/definition.rb
@@ -40,9 +40,19 @@ def generate_bitmasks_on(model)
end
def override(model)
+ override_dup(model)
override_getter_on(model)
override_setter_on(model)
end
+
+ def override_dup(model)
+ model.class_eval %(
+ def dup
+ @#{attribute} = nil
+ super
+ end
+ )
+ end
def override_getter_on(model)
model.class_eval %(

0 comments on commit b27a343

Please sign in to comment.