store-memory 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/store/memory/version.rb +1 -1
- data/lib/store/memory.rb +20 -12
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25cf8a3bda43b3c159ab59944e48fe1c8fa22af1
|
4
|
+
data.tar.gz: 01f0183cc781f046f61a9d598c2b05d02de79a3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fc9d1652882e369a764c0b9da000a3ca901f5a14f89594ab55f53a43bf2ed56d583c1e7ebf7812a2f199556654296f84c3e76664acb69c250742bfd3e4e49ae
|
7
|
+
data.tar.gz: 29f72db4987a71376024eda953768da8bda9825a72311221b6376d4636bb77a72199cc54d0a811f23fc5a61dd723d1be6d7272b7823f2bc46ac502ea3ccc97b7
|
data/lib/store/memory/version.rb
CHANGED
data/lib/store/memory.rb
CHANGED
@@ -23,31 +23,39 @@ class Store
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def delete(id)
|
26
|
-
|
26
|
+
items.delete(id)
|
27
27
|
id
|
28
28
|
end
|
29
29
|
|
30
30
|
def single_find(id)
|
31
|
-
dup(
|
31
|
+
dup(items[id])
|
32
32
|
end
|
33
33
|
|
34
34
|
def bulk_find(ids)
|
35
|
-
|
36
|
-
dup data
|
37
|
-
end
|
35
|
+
collection(items.values_at(*ids))
|
38
36
|
end
|
39
|
-
|
37
|
+
|
38
|
+
def all
|
39
|
+
collection(items.values)
|
40
|
+
end
|
41
|
+
|
40
42
|
def count
|
41
43
|
all.size
|
42
44
|
end
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def collection(items)
|
49
|
+
@result = {}
|
50
|
+
items.map do |data|
|
51
|
+
@result.merge!(data['uid'] => dup(data))
|
47
52
|
end
|
53
|
+
@result
|
54
|
+
end
|
55
|
+
|
56
|
+
def items
|
57
|
+
@items
|
48
58
|
end
|
49
|
-
|
50
|
-
private
|
51
59
|
|
52
60
|
def next_id
|
53
61
|
@id += 1
|