jcnetdev-acts_as_paranoid 1.0.20080706 → 1.1.20080706
Sign up to get free protection for your applications and to get access to all the features.
- data/acts_as_paranoid.gemspec +2 -1
- data/init.rb +1 -30
- data/rails/init.rb +30 -0
- metadata +2 -1
data/acts_as_paranoid.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'acts_as_paranoid'
|
3
|
-
s.version = '1.
|
3
|
+
s.version = '1.1.20080706'
|
4
4
|
s.date = '2008-07-06'
|
5
5
|
|
6
6
|
s.summary = "Allows ActiveRecord models to delete, without actually deleting."
|
@@ -23,6 +23,7 @@ Gem::Specification.new do |s|
|
|
23
23
|
"Rakefile",
|
24
24
|
"acts_as_paranoid.gemspec",
|
25
25
|
"init.rb",
|
26
|
+
"rails/init.rb",
|
26
27
|
"lib/caboose/acts/belongs_to_with_deleted_association.rb",
|
27
28
|
"lib/caboose/acts/has_many_through_without_deleted_association.rb",
|
28
29
|
"lib/caboose/acts/paranoid.rb"]
|
data/init.rb
CHANGED
@@ -1,30 +1 @@
|
|
1
|
-
|
2
|
-
def belongs_to_with_deleted(association_id, options = {})
|
3
|
-
with_deleted = options.delete :with_deleted
|
4
|
-
returning belongs_to_without_deleted(association_id, options) do
|
5
|
-
if with_deleted
|
6
|
-
reflection = reflect_on_association(association_id)
|
7
|
-
association_accessor_methods(reflection, Caboose::Acts::BelongsToWithDeletedAssociation)
|
8
|
-
association_constructor_method(:build, reflection, Caboose::Acts::BelongsToWithDeletedAssociation)
|
9
|
-
association_constructor_method(:create, reflection, Caboose::Acts::BelongsToWithDeletedAssociation)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def has_many_without_deleted(association_id, options = {}, &extension)
|
15
|
-
with_deleted = options.delete :with_deleted
|
16
|
-
returning has_many_with_deleted(association_id, options, &extension) do
|
17
|
-
if options[:through] && !with_deleted
|
18
|
-
reflection = reflect_on_association(association_id)
|
19
|
-
collection_reader_method(reflection, Caboose::Acts::HasManyThroughWithoutDeletedAssociation)
|
20
|
-
collection_accessor_methods(reflection, Caboose::Acts::HasManyThroughWithoutDeletedAssociation, false)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
alias_method_chain :belongs_to, :deleted
|
26
|
-
alias_method :has_many_with_deleted, :has_many
|
27
|
-
alias_method :has_many, :has_many_without_deleted
|
28
|
-
alias_method :exists_with_deleted?, :exists?
|
29
|
-
end
|
30
|
-
ActiveRecord::Base.send :include, Caboose::Acts::Paranoid
|
1
|
+
require File.dirname(__FILE__) + "/rails/init"
|
data/rails/init.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
class << ActiveRecord::Base
|
2
|
+
def belongs_to_with_deleted(association_id, options = {})
|
3
|
+
with_deleted = options.delete :with_deleted
|
4
|
+
returning belongs_to_without_deleted(association_id, options) do
|
5
|
+
if with_deleted
|
6
|
+
reflection = reflect_on_association(association_id)
|
7
|
+
association_accessor_methods(reflection, Caboose::Acts::BelongsToWithDeletedAssociation)
|
8
|
+
association_constructor_method(:build, reflection, Caboose::Acts::BelongsToWithDeletedAssociation)
|
9
|
+
association_constructor_method(:create, reflection, Caboose::Acts::BelongsToWithDeletedAssociation)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def has_many_without_deleted(association_id, options = {}, &extension)
|
15
|
+
with_deleted = options.delete :with_deleted
|
16
|
+
returning has_many_with_deleted(association_id, options, &extension) do
|
17
|
+
if options[:through] && !with_deleted
|
18
|
+
reflection = reflect_on_association(association_id)
|
19
|
+
collection_reader_method(reflection, Caboose::Acts::HasManyThroughWithoutDeletedAssociation)
|
20
|
+
collection_accessor_methods(reflection, Caboose::Acts::HasManyThroughWithoutDeletedAssociation, false)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
alias_method_chain :belongs_to, :deleted
|
26
|
+
alias_method :has_many_with_deleted, :has_many
|
27
|
+
alias_method :has_many, :has_many_without_deleted
|
28
|
+
alias_method :exists_with_deleted?, :exists?
|
29
|
+
end
|
30
|
+
ActiveRecord::Base.send :include, Caboose::Acts::Paranoid
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jcnetdev-acts_as_paranoid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.20080706
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rick Olson
|
@@ -37,6 +37,7 @@ files:
|
|
37
37
|
- Rakefile
|
38
38
|
- acts_as_paranoid.gemspec
|
39
39
|
- init.rb
|
40
|
+
- rails/init.rb
|
40
41
|
- lib/caboose/acts/belongs_to_with_deleted_association.rb
|
41
42
|
- lib/caboose/acts/has_many_through_without_deleted_association.rb
|
42
43
|
- lib/caboose/acts/paranoid.rb
|