jcnetdev-acts_as_paranoid 1.2.20080706 → 1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'acts_as_paranoid'
3
- s.version = '1.2.20080706'
4
- s.date = '2008-07-06'
3
+ s.version = '1.3'
4
+ s.date = '2008-07-17'
5
5
 
6
6
  s.summary = "Allows ActiveRecord models to delete, without actually deleting."
7
7
  s.description = "Overrides some basic methods for the current model so that calling #destroy sets a 'deleted_at' field to the current timestamp. ActiveRecord is required."
@@ -26,7 +26,8 @@ Gem::Specification.new do |s|
26
26
  "rails/init.rb",
27
27
  "lib/caboose/acts/belongs_to_with_deleted_association.rb",
28
28
  "lib/caboose/acts/has_many_through_without_deleted_association.rb",
29
- "lib/caboose/acts/paranoid.rb"]
29
+ "lib/caboose/acts/paranoid.rb",
30
+ "lib/acts_as_paranoid.rb"]
30
31
 
31
32
 
32
33
  s.test_files =["test/database.yml",
@@ -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.2.20080706
4
+ version: "1.3"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rick Olson
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-07-06 00:00:00 -07:00
12
+ date: 2008-07-17 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -41,6 +41,7 @@ files:
41
41
  - lib/caboose/acts/belongs_to_with_deleted_association.rb
42
42
  - lib/caboose/acts/has_many_through_without_deleted_association.rb
43
43
  - lib/caboose/acts/paranoid.rb
44
+ - lib/acts_as_paranoid.rb
44
45
  has_rdoc: true
45
46
  homepage: http://github.com/technoweenie/acts_as_paranoid
46
47
  post_install_message: