storage_unit 0.0.2 → 0.1.0

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: eba1b54d63d57e4b4b4e2149754272ac180cce08
4
- data.tar.gz: 4754737dec10ea3d2e116926cc31349315b4791d
3
+ metadata.gz: e9b686097ab6166d0cd66e90befe241fe8e0d256
4
+ data.tar.gz: 0ffecafa0a2ed6be9eea6c9df9458ae4b6955158
5
5
  SHA512:
6
- metadata.gz: a650824e8575059391dedbf25751f2ae5ad738d4678a65cdc599a94c87f985548d40acde3bcd59703f7a996304e2a5ba0ede390d1a8360a974b51c375c8e8996
7
- data.tar.gz: c6247d85de6378b7f2850d73cbd748cbe57741c09a6ab744658203a86019a4869394fe181ec3e86336284c063d3bd9f6e05690af3a0a88734e15e1fd34671b96
6
+ metadata.gz: e3dce4c8c63d991a29fb95b81b55e76c4471fd4414b195af8429cf0eee6326d688ef80b5325895c659c0b0fa9c6dc9fb94c73b9e3c9553632e44f18c7522bf8c
7
+ data.tar.gz: 21d4d67daffd46dc445769bd42781a512cff16a959b5591fc1727ce46a607680a2ccbbb78293d98424f78f2dfeb8014c63661c66410386857208da52de14f6ff
data/README.md CHANGED
@@ -46,7 +46,11 @@ post.trashed? # => false
46
46
  post.trash!
47
47
  post.trashed? # => true
48
48
  Post.all # => []
49
- Post.with_deleted.all # => [post]
49
+ Post.with_deleted # => [post]
50
+
51
+ new_post = Post.create
52
+ Post.with_deleted # => [post, new_post]
53
+ Post.deleted_only # => [post]
50
54
 
51
55
  post.recover!
52
56
  post.trashed? # => false
@@ -13,6 +13,10 @@ module StorageUnit
13
13
  all.table[storage_unit_opts[:column]].eq(nil).to_sql
14
14
  end
15
15
 
16
+ def deleted_only_scope_sql
17
+ all.table[storage_unit_opts[:column]].not_eq(nil).to_sql
18
+ end
19
+
16
20
  # lifted from acts_as_paranoid, works around https://github.com/rails/rails/issues/4306
17
21
  # with this in place Post.limit(10).with_deleted, will work as expected
18
22
  def with_deleted
@@ -20,6 +24,10 @@ module StorageUnit
20
24
  scope.where_values.delete(with_deleted_scope_sql)
21
25
  scope
22
26
  end
27
+
28
+ def deleted_only
29
+ with_deleted.where(deleted_only_scope_sql)
30
+ end
23
31
  end
24
32
 
25
33
  def trashed?
@@ -1,3 +1,3 @@
1
1
  module StorageUnit
2
- VERSION = '0.0.2'
2
+ VERSION = '0.1.0'
3
3
  end
@@ -90,6 +90,15 @@ describe 'Default scope' do
90
90
  end
91
91
  end
92
92
 
93
+ describe '.deleted_only' do
94
+ let!(:user) { User.create }
95
+ let!(:deleted_user) { User.create(deleted_at: Time.now) }
96
+
97
+ it 'functions properly' do
98
+ expect(User.deleted_only.count).to eq 1
99
+ end
100
+ end
101
+
93
102
  describe '#trashed?' do
94
103
  let!(:user) { User.create }
95
104
  subject { user }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: storage_unit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Becker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-07 00:00:00.000000000 Z
11
+ date: 2016-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails