Commit 9a26d811 by John Hawthorn Committed by GitHub

Merge pull request #436 from jhawthorn/rails_5_2_patches

Improvements to rails 5.2 patches
parents 82ba504e c33f3a65
require 'active_record' unless defined? ActiveRecord require 'active_record' unless defined? ActiveRecord
require 'paranoia/active_record_patches'
if [ActiveRecord::VERSION::MAJOR, ActiveRecord::VERSION::MINOR] == [5, 2]
require 'paranoia/active_record_5_2'
end
module Paranoia module Paranoia
@@default_sentinel_value = nil @@default_sentinel_value = nil
......
...@@ -5,8 +5,8 @@ module HandleParanoiaDestroyedInBelongsToAssociation ...@@ -5,8 +5,8 @@ module HandleParanoiaDestroyedInBelongsToAssociation
case options[:dependent] case options[:dependent]
when :destroy when :destroy
target.destroy target.destroy
if defined? target.deleted? if target.respond_to?(:paranoia_destroyed?)
raise ActiveRecord::Rollback unless target.deleted? raise ActiveRecord::Rollback unless target.paranoia_destroyed?
else else
raise ActiveRecord::Rollback unless target.destroyed? raise ActiveRecord::Rollback unless target.destroyed?
end end
...@@ -25,8 +25,8 @@ module HandleParanoiaDestroyedInHasOneAssociation ...@@ -25,8 +25,8 @@ module HandleParanoiaDestroyedInHasOneAssociation
when :destroy when :destroy
target.destroyed_by_association = reflection target.destroyed_by_association = reflection
target.destroy target.destroy
if defined? target.deleted? if target.respond_to?(:paranoia_destroyed?)
throw(:abort) unless target.deleted? throw(:abort) unless target.paranoia_destroyed?
else else
throw(:abort) unless target.destroyed? throw(:abort) unless target.destroyed?
end end
......
...@@ -24,7 +24,7 @@ Gem::Specification.new do |s| ...@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
s.required_ruby_version = '>= 2.0' s.required_ruby_version = '>= 2.0'
s.add_dependency 'activerecord', '>= 4.0', '< 5.2' s.add_dependency 'activerecord', '>= 4.0', '< 5.3'
s.add_development_dependency "bundler", ">= 1.0.0" s.add_development_dependency "bundler", ">= 1.0.0"
s.add_development_dependency "rake" s.add_development_dependency "rake"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment