paranoia 2.4.0 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: aab51c0ba1c7cc66a301e165f34ba63c47428180
4
- data.tar.gz: 3afafc557c633dbc11e230f919c0a6f4366b5d0e
2
+ SHA256:
3
+ metadata.gz: d25bfc4e0254aba4db5a58da8d666c68052e836bc2f315efbcd5ec2b77657b30
4
+ data.tar.gz: d413ea576910faa0e4ebaff07c617c8692db837beeb24a5d5d43d0794170981f
5
5
  SHA512:
6
- metadata.gz: 0e427b3d1e96e08551b0f20350dcd0f5e3739b124c8c6aba82c124055f743620bc170849525e67da16e791272ab484730a734199c358f3adac3b7ec6de0a6626
7
- data.tar.gz: bf2c134c11990eb5766911fb6aba323fb2b35320bbc6dcdb700c45df60cc1fdea89827f3ee35fc4d120a6ef8a877792fe5b5f7ecc72852727792c4f5c493612e
6
+ metadata.gz: 354429a32eb5c97b1662456e56a5df64ff8b2c0d4ae02e57d528384eb33c17a161f5972275babfd55c279f7de54552073ae425c9a2c4b676a383ca55c83a8cfe
7
+ data.tar.gz: 3f5e1914d1f200e82c8e1775bf2859e253b7aa6b434eaaf841276db9f017185f0f985ff7ef80ed53d103b1f21762419315568aa097a662946aab85db28431369
@@ -1,10 +1,12 @@
1
1
  sudo: false
2
2
  language: ruby
3
+ before_install: gem update --system
3
4
  cache: bundler
4
5
  rvm:
5
- - 2.2.7
6
- - 2.3.4
7
- - 2.4.1
6
+ - 2.2
7
+ - 2.3.5
8
+ - 2.4.3
9
+ - 2.5.0
8
10
  - jruby-9.1.6.0
9
11
 
10
12
  env:
@@ -12,6 +14,7 @@ env:
12
14
  - RAILS='~> 4.2.0'
13
15
  - RAILS='~> 5.0.0'
14
16
  - RAILS='~> 5.1.0'
17
+ - RAILS='~> 5.2.0'
15
18
 
16
19
  matrix:
17
20
  allow_failures:
@@ -21,3 +24,5 @@ matrix:
21
24
  rvm: jruby-9.1.6.0
22
25
  - env: RAILS='~> 5.1.0'
23
26
  rvm: jruby-9.1.6.0
27
+ - env: RAILS='~> 5.2.0'
28
+ rvm: jruby-9.1.6.0
@@ -1,5 +1,11 @@
1
1
  # paranoia Changelog
2
2
 
3
+ ## 2.4.1
4
+
5
+ * [#435](https://github.com/rubysherpas/paranoia/pull/435) Monkeypatch activerecord relations to work with rails 6.2.0
6
+
7
+ [Bartosz Bonisławski (@bbonislawski)](https://github.com/bbonislawski)
8
+
3
9
  ## 2.4.0
4
10
 
5
11
  * [#423](https://github.com/rubysherpas/paranoia/pull/423) Add `paranoia_destroy` and `paranoia_delete` aliases
data/Gemfile CHANGED
@@ -12,7 +12,7 @@ platforms :rbx do
12
12
  gem 'rubinius-developer_tools'
13
13
  end
14
14
 
15
- rails = ENV['RAILS'] || '~> 5.1.0'
15
+ rails = ENV['RAILS'] || '~> 5.2.0'
16
16
 
17
17
  gem 'rails', rails
18
18
 
data/README.md CHANGED
@@ -1,3 +1,9 @@
1
+ **Notice:**
2
+
3
+ `paranoia` has some surprising behaviour (like overriding ActiveRecord's `delete` and `destroy`) and is not recommended for new projects. See [`discard`'s README](https://github.com/jhawthorn/discard#why-not-paranoia-or-acts_as_paranoid) for more details.
4
+
5
+ Paranoia will continue to accept bug fixes and support new versions of Rails but isn't accepting new features.
6
+
1
7
  # Paranoia
2
8
 
3
9
  Paranoia is a re-implementation of [acts\_as\_paranoid](http://github.com/ActsAsParanoid/acts_as_paranoid) for Rails 3/4/5, using much, much, much less code.
@@ -1,5 +1,9 @@
1
1
  require 'active_record' unless defined? ActiveRecord
2
2
 
3
+ if [ActiveRecord::VERSION::MAJOR, ActiveRecord::VERSION::MINOR] == [5, 2]
4
+ require 'paranoia/active_record_5_2'
5
+ end
6
+
3
7
  module Paranoia
4
8
  @@default_sentinel_value = nil
5
9
 
@@ -0,0 +1,41 @@
1
+ module HandleParanoiaDestroyedInBelongsToAssociation
2
+ def handle_dependency
3
+ return unless load_target
4
+
5
+ case options[:dependent]
6
+ when :destroy
7
+ target.destroy
8
+ if target.respond_to?(:paranoia_destroyed?)
9
+ raise ActiveRecord::Rollback unless target.paranoia_destroyed?
10
+ else
11
+ raise ActiveRecord::Rollback unless target.destroyed?
12
+ end
13
+ else
14
+ target.send(options[:dependent])
15
+ end
16
+ end
17
+ end
18
+
19
+ module HandleParanoiaDestroyedInHasOneAssociation
20
+ def delete(method = options[:dependent])
21
+ if load_target
22
+ case method
23
+ when :delete
24
+ target.delete
25
+ when :destroy
26
+ target.destroyed_by_association = reflection
27
+ target.destroy
28
+ if target.respond_to?(:paranoia_destroyed?)
29
+ throw(:abort) unless target.paranoia_destroyed?
30
+ else
31
+ throw(:abort) unless target.destroyed?
32
+ end
33
+ when :nullify
34
+ target.update_columns(reflection.foreign_key => nil) if target.persisted?
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+ ActiveRecord::Associations::BelongsToAssociation.prepend HandleParanoiaDestroyedInBelongsToAssociation
41
+ ActiveRecord::Associations::HasOneAssociation.prepend HandleParanoiaDestroyedInHasOneAssociation
@@ -1,3 +1,3 @@
1
1
  module Paranoia
2
- VERSION = '2.4.0'.freeze
2
+ VERSION = '2.4.1'.freeze
3
3
  end
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
24
24
 
25
25
  s.required_ruby_version = '>= 2.0'
26
26
 
27
- s.add_dependency 'activerecord', '>= 4.0', '< 5.2'
27
+ s.add_dependency 'activerecord', '>= 4.0', '< 5.3'
28
28
 
29
29
  s.add_development_dependency "bundler", ">= 1.0.0"
30
30
  s.add_development_dependency "rake"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paranoia
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - radarlistener@gmail.com
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-03 00:00:00.000000000 Z
11
+ date: 2018-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '4.0'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '5.2'
22
+ version: '5.3'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '4.0'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '5.2'
32
+ version: '5.3'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: bundler
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -83,6 +83,7 @@ files:
83
83
  - README.md
84
84
  - Rakefile
85
85
  - lib/paranoia.rb
86
+ - lib/paranoia/active_record_5_2.rb
86
87
  - lib/paranoia/rspec.rb
87
88
  - lib/paranoia/version.rb
88
89
  - paranoia.gemspec
@@ -107,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
108
  version: 1.3.6
108
109
  requirements: []
109
110
  rubyforge_project:
110
- rubygems_version: 2.6.11
111
+ rubygems_version: 2.7.6
111
112
  signing_key:
112
113
  specification_version: 4
113
114
  summary: Paranoia is a re-implementation of acts_as_paranoid for Rails 3, 4, and 5,