Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
paranoia
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
paranoia
Commits
45155254
Commit
45155254
authored
Jun 16, 2015
by
Ben Woosley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Inline touch_paranoia_column into delete
parent
3b6ff6ec
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
14 deletions
+8
-14
lib/paranoia.rb
+8
-14
No files found.
lib/paranoia.rb
View file @
45155254
...
...
@@ -68,7 +68,7 @@ module Paranoia
def
destroy
transaction
do
run_callbacks
(
:destroy
)
do
result
=
touch_paranoia_column
result
=
delete
if
result
&&
ActiveRecord
::
VERSION
::
STRING
>=
'4.2'
each_counter_cached_associations
do
|
association
|
foreign_key
=
association
.
reflection
.
foreign_key
.
to_sym
...
...
@@ -85,7 +85,13 @@ module Paranoia
end
def
delete
touch_paranoia_column
raise
ActiveRecord
::
ReadOnlyRecord
,
"
#{
self
.
class
}
is marked as readonly"
if
readonly?
if
persisted?
touch
(
paranoia_column
)
elsif
!
frozen?
write_attribute
(
paranoia_column
,
current_time_from_proper_timezone
)
end
self
end
def
restore!
(
opts
=
{})
...
...
@@ -113,18 +119,6 @@ module Paranoia
private
# touch paranoia column.
# insert time to paranoia column.
def
touch_paranoia_column
raise
ActiveRecord
::
ReadOnlyRecord
,
"
#{
self
.
class
}
is marked as readonly"
if
readonly?
if
persisted?
touch
(
paranoia_column
)
elsif
!
frozen?
write_attribute
(
paranoia_column
,
current_time_from_proper_timezone
)
end
self
end
# restore associated records that have been soft deleted when
# we called #destroy
def
restore_associated_records
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment