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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7f7d90ccdf68a5f7982f1f0e456481185c328f97
4
- data.tar.gz: 074a1fb8b2112f4df91efe51d2d0caa99ebe5b81
3
+ metadata.gz: 7cf0bd7ba8b414a9057afeb58e0d9ae66a478a71
4
+ data.tar.gz: c2e77135d18e928d7307fc63137060ecb765f4b4
5
5
  SHA512:
6
- metadata.gz: 8421ce9ef55652c69e4aa3352c4960a2af5a6ffe0d595381a5c79f2446b8d3001da72428bd823e22aa47004340b2adc5348c74375edccdbcd2ac9d0056118de9
7
- data.tar.gz: 9b561e91101fdd12c9bce674c955112e02cd862c67f00cb5802601bfa6737ebea5db68a2670ac3ecf1c15afcec005501b2b17f94ee56c393cda085e2b40e5151
6
+ metadata.gz: 716a5710e9e38b80a421ed573884d0c9f1263ce88f0186a199bba16ec875b7045c89f077e05e74c5c5e8ac9ffd160ba16fa222cb9bab1bffeab92035e5cc4953
7
+ data.tar.gz: 5848377b3ca7c1c21b81f0b6a497757c10e2997122e02415aa4a83f47a0da0ce753ab9f2777bd98d07429811d25473c897fd21b2f492eefe14dbb65bc107e522
@@ -55,8 +55,12 @@ module RRepo
55
55
  result.map(&method(:model_for))
56
56
  end
57
57
 
58
- def find(id)
59
- result = adapter.find(collection, id)
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 query(&block)
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
@@ -1,3 +1,3 @@
1
1
  module RRepo
2
- VERSION = '0.2.6'.freeze
2
+ VERSION = '0.2.7'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rrepo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joakim Reinert