rrepo 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rrepo/repository.rb +15 -4
- data/lib/rrepo/version.rb +1 -1
- 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: 7cf0bd7ba8b414a9057afeb58e0d9ae66a478a71
|
4
|
+
data.tar.gz: c2e77135d18e928d7307fc63137060ecb765f4b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 716a5710e9e38b80a421ed573884d0c9f1263ce88f0186a199bba16ec875b7045c89f077e05e74c5c5e8ac9ffd160ba16fa222cb9bab1bffeab92035e5cc4953
|
7
|
+
data.tar.gz: 5848377b3ca7c1c21b81f0b6a497757c10e2997122e02415aa4a83f47a0da0ce753ab9f2777bd98d07429811d25473c897fd21b2f492eefe14dbb65bc107e522
|
data/lib/rrepo/repository.rb
CHANGED
@@ -55,8 +55,12 @@ module RRepo
|
|
55
55
|
result.map(&method(:model_for))
|
56
56
|
end
|
57
57
|
|
58
|
-
def find(id)
|
59
|
-
|
58
|
+
def find(id = nil, &block)
|
59
|
+
if block_given?
|
60
|
+
result = adapter.query(collection, &block).run.next_document
|
61
|
+
else
|
62
|
+
result = adapter.find(collection, id)
|
63
|
+
end
|
60
64
|
model_for(result)
|
61
65
|
end
|
62
66
|
|
@@ -64,8 +68,15 @@ module RRepo
|
|
64
68
|
adapter.clear(collection)
|
65
69
|
end
|
66
70
|
|
67
|
-
def
|
68
|
-
adapter.query(collection, &block)
|
71
|
+
def find_all(&block)
|
72
|
+
result = adapter.query(collection, &block).run
|
73
|
+
Enumerator.new do |y|
|
74
|
+
loop do
|
75
|
+
doc = result.next_document
|
76
|
+
break if doc.nil?
|
77
|
+
y << model_for(doc)
|
78
|
+
end
|
79
|
+
end
|
69
80
|
end
|
70
81
|
|
71
82
|
def model_class(attributes = {})
|
data/lib/rrepo/version.rb
CHANGED