Skip to content

Commit

Permalink
detach the BitmaskAttributes::Proxy instance variable on dup
Browse files Browse the repository at this point in the history
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
aduffeck committed Dec 1, 2011
1 parent 1ab3131 commit b27a343
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/bitmask_attributes/definition.rb
Expand Up @@ -40,9 +40,19 @@ def generate_bitmasks_on(model)
end end


def override(model) def override(model)
override_dup(model)
override_getter_on(model) override_getter_on(model)
override_setter_on(model) override_setter_on(model)
end end

def override_dup(model)
model.class_eval %(
def dup
@#{attribute} = nil
super
end
)
end


def override_getter_on(model) def override_getter_on(model)
model.class_eval %( model.class_eval %(
Expand Down

0 comments on commit b27a343

Please sign in to comment.