rails3_acts_as_paranoid 0.2.2 → 0.2.3

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.
@@ -2,10 +2,8 @@ module ActsAsParanoid
2
2
  module Associations
3
3
  def self.included(base)
4
4
  base.extend ClassMethods
5
- base.class_eval do
6
- class << self
7
- alias_method_chain :belongs_to, :deleted
8
- end
5
+ class << base
6
+ alias_method_chain :belongs_to, :deleted
9
7
  end
10
8
  end
11
9
 
@@ -13,12 +11,14 @@ module ActsAsParanoid
13
11
  def belongs_to_with_deleted(target, options = {})
14
12
  with_deleted = options.delete(:with_deleted)
15
13
  result = belongs_to_without_deleted(target, options)
16
-
14
+
17
15
  if with_deleted
18
16
  class_eval <<-RUBY, __FILE__, __LINE__
19
17
  def #{target}_with_unscoped(*args)
20
- return #{target}_without_unscoped(*args) unless association(:#{target}).klass.paranoid?
21
- association(:#{target}).klass.with_deleted.scoping { #{target}_without_unscoped(*args) }
18
+ association = association(:#{target})
19
+ return nil if association.options[:polymorphic] && association.klass.nil?
20
+ return #{target}_without_unscoped(*args) unless association.klass.paranoid?
21
+ association.klass.with_deleted.scoping { #{target}_without_unscoped(*args) }
22
22
  end
23
23
  alias_method_chain :#{target}, :unscoped
24
24
  RUBY
@@ -2,7 +2,6 @@ module ActsAsParanoid
2
2
  module Relation
3
3
  def self.included(base)
4
4
  base.class_eval do
5
-
6
5
  def paranoid?
7
6
  klass.try(:paranoid?) ? true : false
8
7
  end
@@ -25,7 +25,7 @@ module ActsAsParanoid
25
25
  relation = relation.and(table[scope_item].eq(scope_value))
26
26
  end
27
27
 
28
- # Re-add ActsAsParanoid default scope conditions manually.
28
+ # Re-add ActsAsParanoid default scope conditions manually.
29
29
  if finder_class.unscoped.where(finder_class.paranoid_default_scope_sql).where(relation).exists?
30
30
  record.errors.add(attribute, :taken, options.except(:case_sensitive, :scope).merge(:value => value))
31
31
  end
@@ -33,7 +33,6 @@ module ActsAsParanoid
33
33
  return if paranoid?
34
34
 
35
35
  include ActsAsParanoid::Core
36
- include ActsAsParanoid::Associations
37
36
 
38
37
  # Magic!
39
38
  default_scope { where(paranoid_default_scope_sql) }
@@ -52,6 +51,9 @@ end
52
51
  # Extend ActiveRecord's functionality
53
52
  ActiveRecord::Base.send :extend, ActsAsParanoid
54
53
 
54
+ # Extend ActiveRecord::Base with paranoid associations
55
+ ActiveRecord::Base.send :include, ActsAsParanoid::Associations
56
+
55
57
  # Override ActiveRecord::Relation's behavior
56
58
  ActiveRecord::Relation.send :include, ActsAsParanoid::Relation
57
59
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails3_acts_as_paranoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-15 00:00:00.000000000 Z
12
+ date: 2012-05-16 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
16
- requirement: &70127635131740 !ruby/object:Gem::Requirement
16
+ requirement: &70257574323260 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '3.2'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70127635131740
24
+ version_requirements: *70257574323260
25
25
  description: Active Record (~>3.2) plugin which allows you to hide and restore records
26
26
  without actually deleting them. Check its GitHub page for more in-depth information.
27
27
  email:
@@ -51,7 +51,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
51
51
  version: '0'
52
52
  segments:
53
53
  - 0
54
- hash: -64246137281541820
54
+ hash: -4511554032521980208
55
55
  required_rubygems_version: !ruby/object:Gem::Requirement
56
56
  none: false
57
57
  requirements: