destroyed_at 0.1.1 → 0.1.2
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.
- checksums.yaml +4 -4
- data/lib/destroyed_at.rb +4 -3
- data/lib/destroyed_at/version.rb +1 -1
- data/test/destroyed_at_test.rb +3 -3
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31f75d25de69694f1b0550d6acfa484ecfa0332f
|
4
|
+
data.tar.gz: 415f0de4a3c8dfadfb647f08fe0fb51b723cc808
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52ab8675b98527803e9f4d012e51259a5c975ba468419262527a70ef2e3f6acb9c5f53fff94dc5f2342903bf7990d3ccc3ccb76e0ce27f79d844bcce436720a5
|
7
|
+
data.tar.gz: 96056fbf155a22dc22e5170e7dc95334fd1b226b379249de334e14259d4e01b7079e089a1b61b0a6640ef68d51a5be4ff34f67b62152079d308e513dcdc3635f
|
data/lib/destroyed_at.rb
CHANGED
@@ -13,7 +13,7 @@ module DestroyedAt
|
|
13
13
|
def destroy
|
14
14
|
run_callbacks(:destroy) do
|
15
15
|
destroy_associations
|
16
|
-
self.update_attribute(:destroyed_at,
|
16
|
+
self.update_attribute(:destroyed_at, current_time_from_proper_timezone)
|
17
17
|
@destroyed = true
|
18
18
|
end
|
19
19
|
end
|
@@ -33,7 +33,7 @@ module DestroyedAt
|
|
33
33
|
private
|
34
34
|
|
35
35
|
def _set_destruction_state
|
36
|
-
@destroyed = destroyed_at.present? if
|
36
|
+
@destroyed = destroyed_at.present? if has_attribute?(:destroyed_at)
|
37
37
|
# Don't stop the other callbacks from running
|
38
38
|
true
|
39
39
|
end
|
@@ -44,7 +44,8 @@ module DestroyedAt
|
|
44
44
|
if assoc.options[:through] && assoc.options[:dependent] == :destroy
|
45
45
|
assoc = association(assoc.options[:through])
|
46
46
|
end
|
47
|
-
|
47
|
+
relation = assoc.respond_to?(:scope) ? assoc.scope : assoc.scoped
|
48
|
+
relation.unscoped.each { |r| r.restore if r.respond_to? :restore }
|
48
49
|
end
|
49
50
|
end
|
50
51
|
end
|
data/lib/destroyed_at/version.rb
CHANGED
data/test/destroyed_at_test.rb
CHANGED
@@ -9,11 +9,11 @@ describe 'Destroying AR models' do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'Destroying a model will set the timestamp it was destroyed at' do
|
12
|
-
|
13
|
-
Timecop.freeze(
|
12
|
+
time = Time.now
|
13
|
+
Timecop.freeze(time) do
|
14
14
|
user = User.create
|
15
15
|
user.destroy
|
16
|
-
user.destroyed_at.
|
16
|
+
user.destroyed_at.must_equal time
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: destroyed_at
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Dupuis Jr.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -174,10 +174,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
174
|
version: '0'
|
175
175
|
requirements: []
|
176
176
|
rubyforge_project:
|
177
|
-
rubygems_version: 2.0.
|
177
|
+
rubygems_version: 2.0.0
|
178
178
|
signing_key:
|
179
179
|
specification_version: 4
|
180
180
|
summary: Safe destroy for ActiveRecord.
|
181
181
|
test_files:
|
182
182
|
- test/destroyed_at_test.rb
|
183
183
|
- test/test_helper.rb
|
184
|
+
has_rdoc:
|