destroyed_at 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d0cbd15c416464ff4ef00e2af5b0a037bf72691e
4
- data.tar.gz: 7f0cdd43d097e1f28b8c557ba444fa1f0befc6f6
3
+ metadata.gz: 31f75d25de69694f1b0550d6acfa484ecfa0332f
4
+ data.tar.gz: 415f0de4a3c8dfadfb647f08fe0fb51b723cc808
5
5
  SHA512:
6
- metadata.gz: bb3d75a9b8ab6488912479cc5623556f4f23e84d2235ecd6b668e1a2417037abf43ee377aa27b26504fb32a8878e0cb8c92540f3a6188d231dc917c2e5b9f2aa
7
- data.tar.gz: ca2b3311fcec370efa0d5ab14d0fa6c5b11b7a36e8282f931f54501f399c173c2c0d0d18af81f124e49afb66351510ac268631eb89fbf239f990712133c32079
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, DateTime.current)
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 respond_to?(:destroyed_at)
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
- assoc.scoped.unscoped.each { |r| r.restore if r.respond_to? :restore }
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
@@ -1,3 +1,3 @@
1
1
  module DestroyedAt
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -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
- date = DateTime.current
13
- Timecop.freeze(date) do
12
+ time = Time.now
13
+ Timecop.freeze(time) do
14
14
  user = User.create
15
15
  user.destroy
16
- user.destroyed_at.inspect.must_equal date.inspect
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.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-07-12 00:00:00.000000000 Z
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.3
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: