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
49b028ec
Commit
49b028ec
authored
Jan 06, 2016
by
John Hawthorn
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #292 from jhawthorn/ruby_2_3
Fix really_destroy! for ruby 2.3
parents
7a617a42
dcfd8ca5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
24 deletions
+25
-24
.travis.yml
+1
-0
lib/paranoia.rb
+24
-24
No files found.
.travis.yml
View file @
49b028ec
...
...
@@ -4,6 +4,7 @@ rvm:
-
2.0.0
-
2.1.0
-
2.2.0
-
2.3.0
-
jruby-19mode
env
:
...
...
lib/paranoia.rb
View file @
49b028ec
...
...
@@ -125,6 +125,30 @@ module Paranoia
end
alias
:deleted?
:paranoia_destroyed?
def
really_destroy!
transaction
do
run_callbacks
(
:real_destroy
)
do
dependent_reflections
=
self
.
class
.
reflections
.
select
do
|
name
,
reflection
|
reflection
.
options
[
:dependent
]
==
:destroy
end
if
dependent_reflections
.
any?
dependent_reflections
.
each
do
|
name
,
reflection
|
association_data
=
self
.
send
(
name
)
# has_one association can return nil
# .paranoid? will work for both instances and classes
next
unless
association_data
&&
association_data
.
paranoid?
if
reflection
.
collection?
next
association_data
.
with_deleted
.
each
(
&
:really_destroy!
)
end
association_data
.
really_destroy!
end
end
write_attribute
(
paranoia_column
,
current_time_from_proper_timezone
)
destroy_without_paranoia
end
end
end
private
def
paranoia_restore_attributes
...
...
@@ -185,31 +209,7 @@ class ActiveRecord::Base
def
self
.
acts_as_paranoid
(
options
=
{})
alias
:really_destroyed?
:destroyed?
alias
:really_delete
:delete
alias
:destroy_without_paranoia
:destroy
def
really_destroy!
transaction
do
run_callbacks
(
:real_destroy
)
do
dependent_reflections
=
self
.
class
.
reflections
.
select
do
|
name
,
reflection
|
reflection
.
options
[
:dependent
]
==
:destroy
end
if
dependent_reflections
.
any?
dependent_reflections
.
each
do
|
name
,
reflection
|
association_data
=
self
.
send
(
name
)
# has_one association can return nil
# .paranoid? will work for both instances and classes
next
unless
association_data
&&
association_data
.
paranoid?
if
reflection
.
collection?
next
association_data
.
with_deleted
.
each
(
&
:really_destroy!
)
end
association_data
.
really_destroy!
end
end
write_attribute
(
paranoia_column
,
current_time_from_proper_timezone
)
destroy_without_paranoia
end
end
end
include
Paranoia
class_attribute
:paranoia_column
,
:paranoia_sentinel_value
...
...
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