rrepo 0.2.1 → 0.2.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: 49e52748c010ba63d35b303c12e9995c34dea5da
4
- data.tar.gz: 4a247e20420bf65aee98f681992f7a8a0c47a26e
3
+ metadata.gz: 690bbb86e5cd0139e860c576eb34777247801b3a
4
+ data.tar.gz: 3125867972c8c75cb44c2a567415eda1b1033389
5
5
  SHA512:
6
- metadata.gz: 85089d12dcc06fc13ba1a284a5f8f22ac758d89d8b69798dd7688d513e323677513445749c8216974da3ab4bd4b3527e3809aac9c7515182faf4f58e05a5b6c8
7
- data.tar.gz: 250ed61c4da0848117341de56d6506d649692f2a643a782bb4b2c15d800033e0e314c18fcc056fd0f2efa942536fa0a36ed1edaff69b98548c4eed4b07e58aa7
6
+ metadata.gz: 7bef670ade1b2d25bcee6bff84d6c68fab10b2ebd1c00fb0e07b75446cae0ce1dff9b8a434f8969f31e536dcfaf3ec9bb17f5371a5a4d3ea682435464ada2c22
7
+ data.tar.gz: b1a52c43cc1d4e9a25a80ad26f0533b8ebd3e23cffafbbe34b2db2bea3017e390cce5e89b18a404f9c44948ab61527599246cc2925ca0868afe2c0e24b66d41a
@@ -15,6 +15,7 @@ module RRepo
15
15
  define_abstract_method :all
16
16
  define_abstract_method :find
17
17
  define_abstract_method :clear
18
+ define_abstract_method :query
18
19
  end
19
20
  end
20
21
  end
@@ -37,6 +37,31 @@ module RRepo
37
37
  @db[collection].drop
38
38
  end
39
39
 
40
+ def query(collection, &block)
41
+ Query.new(@db[collection], &block)
42
+ end
43
+
44
+ # A Mongo Query object
45
+ class Query
46
+ def initialize(collection, &block)
47
+ @collection = collection
48
+ @query = {}
49
+ instance_eval(&block) if block_given?
50
+ end
51
+
52
+ def where(condition)
53
+ @query.merge(condition)
54
+ end
55
+
56
+ def run
57
+ @collection.find(@query)
58
+ end
59
+
60
+ def to_hash
61
+ @query
62
+ end
63
+ end
64
+
40
65
  protected
41
66
 
42
67
  def id_query(id)
@@ -66,5 +66,9 @@ module RRepo
66
66
  def clear
67
67
  adapter.clear(collection)
68
68
  end
69
+
70
+ def query(&block)
71
+ adapter.query(collection, &block)
72
+ end
69
73
  end
70
74
  end
data/lib/rrepo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RRepo
2
- VERSION = '0.2.1'.freeze
2
+ VERSION = '0.2.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rrepo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joakim Reinert
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-03-20 00:00:00.000000000 Z
11
+ date: 2015-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler