Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit b27a3431c846ee9e80c53e8b1a92eeb6ef694ead 1 parent 1ab3131
@aduffeck aduffeck authored
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 %(
Please sign in to comment.
Something went wrong with that request. Please try again.