Skip to content
Browse files

Updates for adapter-mongo 0.7

  • Loading branch information...
1 parent 10e62a3 commit 7b3a4de2b5999dc3f302c34a15b52e1c784f58f3 @jnunemaker committed Nov 7, 2012
Showing with 2 additions and 35 deletions.
  1. +1 −0 Gemfile
  2. +0 −16 lib/toy/mongo/querying.rb
  3. +0 −18 spec/toy/mongo/querying_spec.rb
  4. +1 −1 toystore-mongo.gemspec
View
1 Gemfile
@@ -6,6 +6,7 @@ gem 'rake', '~> 0.9.0'
# keep mongo and bson ext at same version
gem 'mongo', '~> 1.6.0'
gem 'bson_ext', '~> 1.6.0', :require => false
+gem 'adapter-mongo', :path => '/Users/jnunemaker/projects/adapter-mongo'
group(:guard) do
gem 'guard', '~> 1.0.0'
View
16 lib/toy/mongo/querying.rb
@@ -25,22 +25,6 @@ def get(id)
super Plucky.to_object_id(id)
end
- # Mongo does not guarantee sort order when using $in.
- # So we manually sort in ruby for now. Not stoked about
- # this, but it gets the job done.
- def get_multi(*ids)
- ids = ids.flatten
- all(:_id => {'$in' => ids}).sort do |a, b|
- index_a = ids.index(a.id)
- index_b = ids.index(b.id)
- if index_a.nil? || index_b.nil?
- 1
- else
- index_a <=> index_b
- end
- end
- end
-
def query
Plucky::Query.new(adapter.client, :transformer => transformer).object_ids(object_id_attributes)
end
View
18 spec/toy/mongo/querying_spec.rb
@@ -40,22 +40,4 @@
User.get('1234').should be_nil
end
end
-
- describe "#get_multi" do
- before(:each) do
- @user1 = User.create
- @user2 = User.create
- @users = User.get_multi(@user2.id, @user1.id)
- end
-
- it "returns multiple documents in correct order" do
- @users.should == [@user2, @user1]
- end
-
- it "performs one query" do
- User.should_not_receive(:get)
- User.should_receive(:all).once.and_return([])
- User.get_multi(@user1.id, @user2.id)
- end
- end
end
View
2 toystore-mongo.gemspec
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
s.add_dependency 'plucky', '~> 0.5'
s.add_dependency 'toystore', '~> 0.10'
- s.add_dependency 'adapter-mongo', '~> 0.5.5'
+ s.add_dependency 'adapter-mongo', '~> 0.7.0'
s.files = `git ls-files`.split("\n") - ['specs.watchr']
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")

0 comments on commit 7b3a4de

Please sign in to comment.
Something went wrong with that request. Please try again.