Skip to content

Commit

Permalink
allow ActiveRecord update_column to access ActiveRecord destroyed? me…
Browse files Browse the repository at this point in the history
…thod.

Patch stolen from rubysherpas#217 (comment)
  • Loading branch information
littldr committed Apr 10, 2015
1 parent 1318b34 commit 19ecd60
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/paranoia.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,21 @@ def self.paranoia_scope
}
end

def update_columns(*)
@_updating_columns = true
super
ensure
@_updating_columns = false
end

def destroyed?
if @_updating_columns
super
else
send(paranoia_column) != paranoia_sentinel_value
end
end

# Please do not use this method in production.
# Pretty please.
def self.I_AM_THE_DESTROYER!
Expand Down

0 comments on commit 19ecd60

Please sign in to comment.