organizze_permanent_records 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,5 @@
1
- require "organizze_permanent_records/version"
2
-
3
1
  module OrganizzePermanentRecords
4
- def self.included(base)
2
+ def self.included(base)
5
3
 
6
4
  base.send :include, InstanceMethods
7
5
 
@@ -15,7 +13,6 @@ module OrganizzePermanentRecords
15
13
  base.named_scope :not_deleted, :conditions => { :deleted_at => nil }
16
14
  base.instance_eval { define_callbacks :before_revive, :after_revive }
17
15
  base.send :alias_method_chain, :destroy, :permanent_records
18
- base.extend Rails2
19
16
  # Early Rails code
20
17
  else
21
18
  base.extend EarlyRails
@@ -33,37 +30,18 @@ module OrganizzePermanentRecords
33
30
  def deleted
34
31
  where("#{table_name}.deleted_at IS NOT NULL")
35
32
  end
36
-
37
33
  def not_deleted
38
34
  where("#{table_name}.deleted_at IS NULL")
39
35
  end
40
-
41
- def with_deleted(*args)
42
- if args.present?
43
- unscoped.find(args)
44
- else
45
- unscoped
46
- end
47
- end
48
- end
49
-
50
- module Rails2
51
- def with_deleted(*args)
52
- with_exclusive_scope do
53
- find(*args)
54
- end
55
- end
56
36
  end
57
-
37
+
58
38
  module EarlyRails
59
-
60
39
  def with_deleted
61
40
  with_scope :find => {:conditions => "#{quoted_table_name}.deleted_at IS NOT NULL"} do
62
41
  yield
63
42
  end
64
43
  end
65
44
 
66
-
67
45
  def with_not_deleted
68
46
  with_scope :find => {:conditions => "#{quoted_table_name}.deleted_at IS NULL"} do
69
47
  yield
@@ -129,13 +107,12 @@ module OrganizzePermanentRecords
129
107
  return self unless is_permanent?
130
108
  record = self.class
131
109
  record = record.unscoped if active_record_3?
132
- record = record.with_deleted(id)
133
- record.deleted_at = value
110
+ record = record.find(id)
134
111
  begin
135
112
  # we call save! instead of update_attribute so an ActiveRecord::RecordInvalid
136
113
  # error will be raised if the record isn't valid. (This prevents reviving records that
137
114
  # disregard validation constraints,)
138
- record.send(:update_without_callbacks)
115
+ record.update_attribute(:deleted_at, value)
139
116
  @attributes, @attributes_cache = record.attributes, record.attributes
140
117
  rescue Exception => e
141
118
  # trigger dependent record destruction (they were revived before this record,
@@ -156,11 +133,11 @@ module OrganizzePermanentRecords
156
133
  end
157
134
  if active_record_3?
158
135
  _run_destroy_callbacks do
159
- update_without_callbacks
136
+ save(:validate => false)
160
137
  end
161
138
  else
162
139
  run_callbacks :before_destroy
163
- update_without_callbacks
140
+ save(false)
164
141
  run_callbacks :after_destroy
165
142
  end
166
143
  self
@@ -269,3 +246,4 @@ module OrganizzePermanentRecords
269
246
  end
270
247
 
271
248
  ActiveRecord::Base.send :include, OrganizzePermanentRecords
249
+
@@ -1,3 +1,3 @@
1
1
  module OrganizzePermanentRecords
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: organizze_permanent_records
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-05 00:00:00.000000000Z
12
+ date: 2011-12-04 00:00:00.000000000Z
13
13
  dependencies: []
14
14
  description: Never Lose Data. Rather than deleting rows this sets Record#deleted_at
15
15
  and gives you all the scopes you need to work with your data.
@@ -45,7 +45,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
45
45
  version: '0'
46
46
  requirements: []
47
47
  rubyforge_project: organizze_permanent_records
48
- rubygems_version: 1.8.6
48
+ rubygems_version: 1.8.11
49
49
  signing_key:
50
50
  specification_version: 3
51
51
  summary: This gem is a clone of https://github.com/JackDanger/permanent_records. I