mongo_scope 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -1
- data/VERSION +1 -1
- data/examples/the_lonely_example.rb +1 -1
- data/lib/mongo_scope.rb +2 -2
- data/spec/mongo_scope_spec.rb +1 -1
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -39,7 +39,7 @@ From the examples dir
|
|
39
39
|
puts coll.scope_eq(:first_name => /^L/).scope_eq(:age => 27).find.count # 1
|
40
40
|
|
41
41
|
# the raw scope method (this is wrapped by the helper methods)
|
42
|
-
puts coll.
|
42
|
+
puts coll.raw_scope(:op => '$in', :field => :first_name, :val => ['Mike','Lowell']).find.count # 2
|
43
43
|
|
44
44
|
== Copyright
|
45
45
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
@@ -24,4 +24,4 @@ puts coll.scope_gt(:age => 27).find.count # 1
|
|
24
24
|
puts coll.scope_eq(:first_name => /^L/).scope_eq(:age => 27).find.count # 1
|
25
25
|
|
26
26
|
# the raw scope method (this is wrapped by the helper methods)
|
27
|
-
puts coll.
|
27
|
+
puts coll.raw_scope(:op => '$in', :field => :first_name, :val => ['Mike','Lowell']).find.count # 2
|
data/lib/mongo_scope.rb
CHANGED
@@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__),'mongo_scope','util')
|
|
3
3
|
|
4
4
|
module MongoScope
|
5
5
|
module ScopeMethods
|
6
|
-
def
|
6
|
+
def raw_scope(ops)
|
7
7
|
ScopedCollection.new(ops,self)
|
8
8
|
end
|
9
9
|
def scope_eq(ops)
|
@@ -12,7 +12,7 @@ module MongoScope
|
|
12
12
|
end
|
13
13
|
%w(in nin gt lt gte lte ne mod all size exists).each do |op|
|
14
14
|
define_method("scope_#{op}") do |ops|
|
15
|
-
|
15
|
+
raw_scope(:op => "$#{op}", :field => ops.keys.first, :val => ops.values.first)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
data/spec/mongo_scope_spec.rb
CHANGED
@@ -26,7 +26,7 @@ describe "MongoScope" do
|
|
26
26
|
@coll.save({:first_name => 'Lou', :age => 27})
|
27
27
|
end
|
28
28
|
it 'scope method' do
|
29
|
-
@coll.
|
29
|
+
@coll.raw_scope(:op => '$in', :field => :first_name, :val => ['Mike','Dave']).find.count.should == 1
|
30
30
|
end
|
31
31
|
it 'helper method - in' do
|
32
32
|
@coll.scope_in(:first_name => ['Mike','Dave']).find.count.should == 1
|