guard_against_physical_delete 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/.travis.yml +6 -0
- data/Gemfile +20 -0
- data/License.txt +21 -0
- data/README.rdoc +17 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/guard_against_physical_delete.gemspec +54 -0
- data/lib/guard_against_physical_delete.rb +11 -0
- data/lib/guard_against_physical_delete/base.rb +57 -0
- data/lib/guard_against_physical_delete/physical_delete_error.rb +3 -0
- data/lib/guard_against_physical_delete/relation.rb +16 -0
- data/lib/guard_against_physical_delete/support_counter_cache.rb +12 -0
- data/lib/guard_against_physical_delete/support_counter_cache/3.0.10/associations.rb +43 -0
- data/lib/guard_against_physical_delete/support_counter_cache/3.2_and_4.0/associations/builder/belongs_to.rb +50 -0
- data/lib/guard_against_physical_delete/support_counter_cache/associations/builder/belongs_to.rb +59 -0
- metadata +157 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e4f57f099c2f498d498bc4080d1241c0ca4973cc
|
4
|
+
data.tar.gz: 766a9b52dbea30d3d2208da40eeb83dac8f1ffc6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 44ca59e3608e8d8752095629dabdecb5fcfc9e5be8683490569629aa339d94edfb3b7472765937f49558c8a4ce2d92de7c573120762b8182b46d9cbca4473ffc
|
7
|
+
data.tar.gz: 9fb8466de8aa5b87275590a8f185a68757534407b0ad56864906b91ffd06961ed635a14197fe78ec39336216ddb67072cfa7612ccf1737c0e854b9bcc3e0fcd0
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
gem 'activerecord', '>= 3.0.10'
|
9
|
+
gem "bundler"
|
10
|
+
|
11
|
+
group :development do
|
12
|
+
gem 'sqlite3'
|
13
|
+
gem "rdoc", "~> 3.12"
|
14
|
+
gem "jeweler", "~> 1.8.3"
|
15
|
+
gem 'database_cleaner'
|
16
|
+
|
17
|
+
gem 'rspec', '< 2.99'
|
18
|
+
gem 'simplecov', :platforms => [:ruby_19, :ruby_20, :ruby_21]
|
19
|
+
gem 'countdownlatch'
|
20
|
+
end
|
data/License.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2011 COOKPAD Inc.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
= guard_against_physical_delete
|
2
|
+
|
3
|
+
guard_against_physical_delete is monkey patch for ActiveRecord.
|
4
|
+
This patch prevent deleting record physically.
|
5
|
+
set logical delete column name. (default is :deleted_at)
|
6
|
+
Logical.logical_delete_column = :removed_at
|
7
|
+
Logical.first.delete #=> raise GuardAgainstPhysicalDelete::PhysicalDeleteError
|
8
|
+
Logical.physical_delete { Logical.first.delete } #=> allow physical_delete
|
9
|
+
|
10
|
+
== Support
|
11
|
+
active_record 3.0.10, >= 3.2
|
12
|
+
|
13
|
+
== Copyright
|
14
|
+
|
15
|
+
Copyright (c) 2012 morita shingo. See License.txt for
|
16
|
+
further details.
|
17
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "guard_against_physical_delete"
|
18
|
+
gem.homepage = "http://github.com/cookpad/guard_against_physical_delete"
|
19
|
+
#gem.license = "MIT"
|
20
|
+
gem.summary = "Guard against physical delete"
|
21
|
+
gem.description = "Guard against physical delete"
|
22
|
+
gem.email = "morita@cookpad.com"
|
23
|
+
gem.authors = ["MORITA shingo"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
|
29
|
+
Dir['lib/tasks/*.rake'].each { |rake| load rake }
|
30
|
+
|
31
|
+
require 'rspec/core'
|
32
|
+
require 'rspec/core/rake_task'
|
33
|
+
|
34
|
+
RSpec::Core::RakeTask.new(:spec)
|
35
|
+
|
36
|
+
task :default => :spec
|
37
|
+
|
38
|
+
desc "Run all specs with rcov"
|
39
|
+
RSpec::Core::RakeTask.new(:rcov) do |t|
|
40
|
+
t.rcov = true
|
41
|
+
t.rcov_opts = %w{--rails --exclude osx\/objc,gems\/,spec\/,features\/}
|
42
|
+
end
|
43
|
+
|
44
|
+
task :default => :spec
|
45
|
+
|
46
|
+
require 'rdoc/task'
|
47
|
+
Rake::RDocTask.new do |rdoc|
|
48
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
50
|
+
rdoc.title = "guard_against_delete #{version}"
|
51
|
+
rdoc.rdoc_files.include('README*')
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "guard_against_physical_delete"
|
8
|
+
s.version = "1.0.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["MORITA shingo"]
|
12
|
+
s.date = "2012-03-06"
|
13
|
+
s.description = "Guard against physical delete"
|
14
|
+
s.email = "morita@cookpad.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.rdoc"
|
17
|
+
]
|
18
|
+
s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^spec/}) }
|
19
|
+
s.homepage = "http://github.com/cookpad/guard_against_physical_delete"
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
s.rubygems_version = "1.8.15"
|
22
|
+
s.summary = "Guard against physical delete"
|
23
|
+
|
24
|
+
if s.respond_to? :specification_version then
|
25
|
+
s.specification_version = 3
|
26
|
+
|
27
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
28
|
+
s.add_runtime_dependency(%q<activerecord>, [">= 3.0.10"])
|
29
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
30
|
+
s.add_development_dependency(%q<sqlite3>, [">= 0"])
|
31
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
32
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
33
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
|
34
|
+
s.add_development_dependency(%q<database_cleaner>, [">= 0"])
|
35
|
+
else
|
36
|
+
s.add_dependency(%q<activerecord>, [">= 3.0.10"])
|
37
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
38
|
+
s.add_dependency(%q<sqlite3>, [">= 0"])
|
39
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
40
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
41
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
42
|
+
s.add_dependency(%q<database_cleaner>, [">= 0"])
|
43
|
+
end
|
44
|
+
else
|
45
|
+
s.add_dependency(%q<activerecord>, [">= 3.0.10"])
|
46
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
47
|
+
s.add_dependency(%q<sqlite3>, [">= 0"])
|
48
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
49
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
50
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
51
|
+
s.add_dependency(%q<database_cleaner>, [">= 0"])
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
require 'guard_against_physical_delete/physical_delete_error'
|
3
|
+
require 'guard_against_physical_delete/relation'
|
4
|
+
require 'guard_against_physical_delete/base'
|
5
|
+
|
6
|
+
ActiveSupport.on_load :active_record do
|
7
|
+
ActiveRecord::Base.send(:include, GuardAgainstPhysicalDelete::Base)
|
8
|
+
ActiveRecord::Relation.send(:include, GuardAgainstPhysicalDelete::Relation)
|
9
|
+
|
10
|
+
require 'guard_against_physical_delete/support_counter_cache'
|
11
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module GuardAgainstPhysicalDelete
|
2
|
+
module Base
|
3
|
+
def self.included(obj)
|
4
|
+
obj.extend ClassMethods
|
5
|
+
obj.class_eval do
|
6
|
+
class_attribute :logical_delete_column
|
7
|
+
|
8
|
+
class << self
|
9
|
+
alias_method :set_logical_delete_column, :logical_delete_column=
|
10
|
+
end
|
11
|
+
|
12
|
+
set_logical_delete_column :deleted_at
|
13
|
+
end
|
14
|
+
obj.send(:include, InstanceMethods)
|
15
|
+
end
|
16
|
+
|
17
|
+
module ClassMethods
|
18
|
+
|
19
|
+
def physical_delete
|
20
|
+
physical_delete_permission[self.name] += 1
|
21
|
+
yield
|
22
|
+
ensure
|
23
|
+
physical_delete_permission[self.name] -= 1
|
24
|
+
end
|
25
|
+
|
26
|
+
def logical_delete?
|
27
|
+
self.column_names.include? logical_delete_column.to_s
|
28
|
+
end
|
29
|
+
|
30
|
+
def delete_permitted?
|
31
|
+
return true unless physical_delete_permission[self.name].zero?
|
32
|
+
return false if logical_delete?
|
33
|
+
return true
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
THREAD_LOCAL_KEY = :__GuardAgainstPhysicalDelete__thread_local_permission__
|
39
|
+
private_constant :THREAD_LOCAL_KEY if RUBY_VERSION >= '1.9.3'
|
40
|
+
|
41
|
+
def physical_delete_permission
|
42
|
+
Thread.current[THREAD_LOCAL_KEY] ||= Hash.new { |h,k| h[k] = 0 }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
module InstanceMethods
|
47
|
+
def hard_delete
|
48
|
+
self.class.physical_delete { destroy }
|
49
|
+
end
|
50
|
+
|
51
|
+
def soft_delete
|
52
|
+
self.__send__(:"#{self.class.logical_delete_column}=", Time.now)
|
53
|
+
self.save!
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module GuardAgainstPhysicalDelete
|
2
|
+
module Relation
|
3
|
+
def self.included(obj)
|
4
|
+
obj.class_eval do
|
5
|
+
def delete_all_with_check_permit(conditions = nil)
|
6
|
+
unless @klass.delete_permitted?
|
7
|
+
raise GuardAgainstPhysicalDelete::PhysicalDeleteError, @klass.name
|
8
|
+
end
|
9
|
+
delete_all_without_check_permit(conditions)
|
10
|
+
end
|
11
|
+
|
12
|
+
alias_method_chain :delete_all, :check_permit
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
if ActiveRecord::VERSION::STRING >= "4.1"
|
2
|
+
require 'guard_against_physical_delete/support_counter_cache/associations/builder/belongs_to'
|
3
|
+
ActiveRecord::Associations::Builder::BelongsTo.send(:include, GuardAgainstPhysicalDelete::SupportCounterCache::Associations::Builder::BelongsTo)
|
4
|
+
elsif ActiveRecord::VERSION::STRING >= "3.2"
|
5
|
+
require 'guard_against_physical_delete/support_counter_cache/3.2_and_4.0/associations/builder/belongs_to'
|
6
|
+
ActiveRecord::Associations::Builder::BelongsTo.send(:include, GuardAgainstPhysicalDelete::SupportCounterCache::Associations::Builder::BelongsTo)
|
7
|
+
elsif ActiveRecord::VERSION::STRING == "3.0.10"
|
8
|
+
require 'guard_against_physical_delete/support_counter_cache/3.0.10/associations'
|
9
|
+
ActiveRecord::Base.send(:include, GuardAgainstPhysicalDelete::SupportCounterCache::Associations)
|
10
|
+
else
|
11
|
+
raise "guard_against_physical_delete doesn't support ActiveRecord version #{ActiveRecord::VERSION::STRING}"
|
12
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module GuardAgainstPhysicalDelete
|
2
|
+
module SupportCounterCache
|
3
|
+
module Associations
|
4
|
+
def self.included(obj)
|
5
|
+
class << obj
|
6
|
+
def add_counter_cache_callbacks_with_logical_delete(reflection)
|
7
|
+
add_counter_cache_callbacks_without_logical_delete(reflection)
|
8
|
+
return unless logical_delete?
|
9
|
+
add_logical_delete_counter_cache_callback(reflection)
|
10
|
+
end
|
11
|
+
alias_method_chain :add_counter_cache_callbacks, :logical_delete
|
12
|
+
|
13
|
+
def add_logical_delete_counter_cache_callback(reflection)
|
14
|
+
cache_column = reflection.counter_cache_column
|
15
|
+
|
16
|
+
logical_delete_method_name = "belongs_to_counter_cache_before_logical_delete_for_#{reflection.name}".to_sym
|
17
|
+
define_method(logical_delete_method_name) do
|
18
|
+
delete_column = self.logical_delete_column
|
19
|
+
next unless send("#{delete_column}_changed?")
|
20
|
+
next unless send("#{delete_column}_was").nil?
|
21
|
+
association = send(reflection.name)
|
22
|
+
association.class.decrement_counter(cache_column, association.id) unless association.nil?
|
23
|
+
end
|
24
|
+
|
25
|
+
revive_method_name = "belongs_to_counter_cache_before_revive_for_#{reflection.name}".to_sym
|
26
|
+
define_method(revive_method_name) do
|
27
|
+
delete_column = self.logical_delete_column
|
28
|
+
next unless send("#{delete_column}_changed?")
|
29
|
+
next if send("#{delete_column}_was").nil?
|
30
|
+
next unless send(delete_column).nil?
|
31
|
+
|
32
|
+
clear_association_cache
|
33
|
+
association = send(reflection.name)
|
34
|
+
association.class.increment_counter(cache_column, association.id) unless association.nil?
|
35
|
+
end
|
36
|
+
|
37
|
+
before_update(logical_delete_method_name, revive_method_name)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module GuardAgainstPhysicalDelete
|
2
|
+
module SupportCounterCache
|
3
|
+
module Associations
|
4
|
+
module Builder
|
5
|
+
module BelongsTo
|
6
|
+
def self.included(obj)
|
7
|
+
obj.class_eval do
|
8
|
+
def add_counter_cache_callbacks_with_logical_delete(reflection)
|
9
|
+
add_counter_cache_callbacks_without_logical_delete(reflection)
|
10
|
+
return unless model.logical_delete?
|
11
|
+
add_logical_delete_counter_cache_callback(reflection)
|
12
|
+
end
|
13
|
+
alias_method_chain :add_counter_cache_callbacks, :logical_delete
|
14
|
+
|
15
|
+
def add_logical_delete_counter_cache_callback(reflection)
|
16
|
+
cache_column = reflection.counter_cache_column
|
17
|
+
name = self.name
|
18
|
+
|
19
|
+
logical_delete_method_name = "belongs_to_counter_cache_after_logical_delete_for_#{name}".to_sym
|
20
|
+
mixin.redefine_method(logical_delete_method_name) do
|
21
|
+
delete_column = self.logical_delete_column
|
22
|
+
next unless send("#{delete_column}_changed?")
|
23
|
+
next unless send("#{delete_column}_was").nil?
|
24
|
+
record = send(name)
|
25
|
+
record.class.decrement_counter(cache_column, record.id) unless record.nil?
|
26
|
+
end
|
27
|
+
|
28
|
+
mixin.redefine_method("belongs_to_counter_cache_after_update_for_#{name}") do
|
29
|
+
# do nothing
|
30
|
+
end if mixin.method_defined?("belongs_to_counter_cache_after_update_for_#{name}")
|
31
|
+
|
32
|
+
revive_method_name = "belongs_to_counter_cache_after_revive_for_#{name}".to_sym
|
33
|
+
|
34
|
+
mixin.redefine_method(revive_method_name) do
|
35
|
+
delete_column = self.logical_delete_column
|
36
|
+
next unless send("#{delete_column}_changed?")
|
37
|
+
next if send("#{delete_column}_was").nil?
|
38
|
+
next unless send(delete_column).nil?
|
39
|
+
record = send(name)
|
40
|
+
record.class.increment_counter(cache_column, record.id) unless record.nil?
|
41
|
+
end
|
42
|
+
model.after_update(logical_delete_method_name, revive_method_name)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/guard_against_physical_delete/support_counter_cache/associations/builder/belongs_to.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
module GuardAgainstPhysicalDelete
|
2
|
+
module SupportCounterCache
|
3
|
+
module Associations
|
4
|
+
module Builder
|
5
|
+
module BelongsTo
|
6
|
+
def self.included(obj)
|
7
|
+
class << obj
|
8
|
+
private
|
9
|
+
def add_counter_cache_methods_with_logical_delete(mixin)
|
10
|
+
add_counter_cache_methods_without_logical_delete mixin
|
11
|
+
add_logical_delete_counter_cache_methods(mixin)
|
12
|
+
end
|
13
|
+
alias_method_chain :add_counter_cache_methods, :logical_delete
|
14
|
+
|
15
|
+
def add_logical_delete_counter_cache_methods(mixin)
|
16
|
+
mixin.class_eval do
|
17
|
+
def belongs_to_counter_cache_after_logical_delete(reflection)
|
18
|
+
cache_column = reflection.counter_cache_column
|
19
|
+
delete_column = self.logical_delete_column
|
20
|
+
return unless send("#{delete_column}_changed?")
|
21
|
+
return unless send("#{delete_column}_was").nil?
|
22
|
+
|
23
|
+
record = send(reflection.name)
|
24
|
+
record.class.decrement_counter(cache_column, record.id) unless record.nil?
|
25
|
+
end
|
26
|
+
|
27
|
+
def belongs_to_counter_cache_after_revive(reflection)
|
28
|
+
cache_column = reflection.counter_cache_column
|
29
|
+
delete_column = self.logical_delete_column
|
30
|
+
return unless send("#{delete_column}_changed?")
|
31
|
+
return if send("#{delete_column}_was").nil?
|
32
|
+
return unless send(delete_column).nil?
|
33
|
+
record = send(reflection.name)
|
34
|
+
record.class.increment_counter(cache_column, record.id) unless record.nil?
|
35
|
+
end
|
36
|
+
end
|
37
|
+
mixin.redefine_method("belongs_to_counter_cache_after_update_for_#{name}") do
|
38
|
+
# do nothing
|
39
|
+
end if mixin.method_defined?("belongs_to_counter_cache_after_update_for_#{name}")
|
40
|
+
end
|
41
|
+
|
42
|
+
def add_counter_cache_callbacks_with_logical_delete(model, reflection)
|
43
|
+
add_counter_cache_callbacks_without_logical_delete model, reflection
|
44
|
+
|
45
|
+
return unless model.logical_delete?
|
46
|
+
|
47
|
+
model.after_update lambda { |record|
|
48
|
+
record.belongs_to_counter_cache_after_logical_delete(reflection)
|
49
|
+
record.belongs_to_counter_cache_after_revive(reflection)
|
50
|
+
}
|
51
|
+
end
|
52
|
+
alias_method_chain :add_counter_cache_callbacks, :logical_delete
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
metadata
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: guard_against_physical_delete
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- MORITA shingo
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2012-03-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activerecord
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.0.10
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.0.10
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sqlite3
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rdoc
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.12'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.12'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.0.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.0.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: jeweler
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.8.3
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.8.3
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: database_cleaner
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: Guard against physical delete
|
112
|
+
email: morita@cookpad.com
|
113
|
+
executables: []
|
114
|
+
extensions: []
|
115
|
+
extra_rdoc_files:
|
116
|
+
- README.rdoc
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- ".travis.yml"
|
120
|
+
- Gemfile
|
121
|
+
- License.txt
|
122
|
+
- README.rdoc
|
123
|
+
- Rakefile
|
124
|
+
- VERSION
|
125
|
+
- guard_against_physical_delete.gemspec
|
126
|
+
- lib/guard_against_physical_delete.rb
|
127
|
+
- lib/guard_against_physical_delete/base.rb
|
128
|
+
- lib/guard_against_physical_delete/physical_delete_error.rb
|
129
|
+
- lib/guard_against_physical_delete/relation.rb
|
130
|
+
- lib/guard_against_physical_delete/support_counter_cache.rb
|
131
|
+
- lib/guard_against_physical_delete/support_counter_cache/3.0.10/associations.rb
|
132
|
+
- lib/guard_against_physical_delete/support_counter_cache/3.2_and_4.0/associations/builder/belongs_to.rb
|
133
|
+
- lib/guard_against_physical_delete/support_counter_cache/associations/builder/belongs_to.rb
|
134
|
+
homepage: http://github.com/cookpad/guard_against_physical_delete
|
135
|
+
licenses: []
|
136
|
+
metadata: {}
|
137
|
+
post_install_message:
|
138
|
+
rdoc_options: []
|
139
|
+
require_paths:
|
140
|
+
- lib
|
141
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
151
|
+
requirements: []
|
152
|
+
rubyforge_project:
|
153
|
+
rubygems_version: 2.4.5.1
|
154
|
+
signing_key:
|
155
|
+
specification_version: 3
|
156
|
+
summary: Guard against physical delete
|
157
|
+
test_files: []
|