Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add spec for multikey (tags) searching; fix Collection#indexes to ret…

…urn indexes only for current namespace
  • Loading branch information...
commit 06180815ad353ba98f5345bcf51e46582c32a572 1 parent f0c4e79
@tmm1 authored
Showing with 21 additions and 1 deletion.
  1. +20 −0 lib/mongo.rb
  2. +1 −1  lib/mongo/collection.rb
View
20 lib/mongo.rb
@@ -146,6 +146,26 @@ def Mongo namespace, client = nil
end
end
+ @editors = @mongo.editors
+ @editors.remove({})
+ @editors.index :platform
+
+ [ { :name => :textmate, :platform => [:osx] },
+ { :name => :vim, :platform => [:osx, :linux] },
+ { :name => :eclipse, :platform => [:osx, :linux, :windows] },
+ { :name => :notepad, :platform => [:windows] }
+ ].each do |obj|
+ @editors.insert obj
+ end
+
+ should 'find objects with given tag' do
+ @editors.find(:platform => :osx) do |res|
+ res.size.should == 3
+ res.map{|r| r[:name].to_s }.sort.should == %w[ eclipse textmate vim ]
+ done
+ end
+ end
+
end
__END__
View
2  lib/mongo/collection.rb
@@ -87,7 +87,7 @@ def index obj
def indexes obj = {}, &blk
@indexes ||= self.class.new("#{@ns.split('.').first}.system.indexes")
- blk ? @indexes.find(obj, &blk) : @indexes
+ blk ? @indexes.find(obj.merge(:ns => @ns), &blk) : @indexes
end
def method_missing meth
Please sign in to comment.
Something went wrong with that request. Please try again.