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
87f8a0c1
Commit
87f8a0c1
authored
Nov 02, 2017
by
John Hawthorn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use paranoia_ aliases internally
This makes paranoia's code itself more explicit.
parent
f6448c4a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
lib/paranoia.rb
+4
-4
No files found.
lib/paranoia.rb
View file @
87f8a0c1
...
...
@@ -56,7 +56,7 @@ module Paranoia
transaction
do
run_callbacks
(
:destroy
)
do
@_disable_counter_cache
=
deleted?
result
=
delete
result
=
paranoia_
delete
next
result
unless
result
&&
ActiveRecord
::
VERSION
::
STRING
>=
'4.2'
each_counter_cached_associations
do
|
association
|
foreign_key
=
association
.
reflection
.
foreign_key
.
to_sym
...
...
@@ -93,7 +93,7 @@ module Paranoia
# This only happened on Rails versions earlier than 4.1.
noop_if_frozen
=
ActiveRecord
.
version
<
Gem
::
Version
.
new
(
"4.1"
)
if
within_recovery_window?
(
recovery_window_range
)
&&
((
noop_if_frozen
&&
!
@attributes
.
frozen?
)
||
!
noop_if_frozen
)
@_disable_counter_cache
=
!
delet
ed?
@_disable_counter_cache
=
!
paranoia_destroy
ed?
write_attribute
paranoia_column
,
paranoia_sentinel_value
update_columns
(
paranoia_restore_attributes
)
each_counter_cached_associations
do
|
association
|
...
...
@@ -130,7 +130,7 @@ module Paranoia
def
really_destroy!
transaction
do
run_callbacks
(
:real_destroy
)
do
@_disable_counter_cache
=
delet
ed?
@_disable_counter_cache
=
paranoia_destroy
ed?
dependent_reflections
=
self
.
class
.
reflections
.
select
do
|
name
,
reflection
|
reflection
.
options
[
:dependent
]
==
:destroy
end
...
...
@@ -300,7 +300,7 @@ module ActiveRecord
class
AssociationNotSoftDestroyedValidator
<
ActiveModel
::
EachValidator
def
validate_each
(
record
,
attribute
,
value
)
# if association is soft destroyed, add an error
if
value
.
present?
&&
value
.
delet
ed?
if
value
.
present?
&&
value
.
paranoia_destroy
ed?
record
.
errors
[
attribute
]
<<
'has been soft-deleted'
end
end
...
...
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