From 28796ac7deb9ffb303cb6792b3bbd20138742d9b Mon Sep 17 00:00:00 2001 From: John Ewart Date: Wed, 14 Dec 2011 17:49:08 -0800 Subject: [PATCH] Support :db key for :out in map_reduce References RUBY-389 --- lib/mongo/collection.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/mongo/collection.rb b/lib/mongo/collection.rb index b5b98a5..7cd0b36 100644 --- a/lib/mongo/collection.rb +++ b/lib/mongo/collection.rb @@ -624,7 +624,12 @@ module Mongo if raw result elsif result["result"] - @db[result["result"]] + if result['result'].is_a? BSON::OrderedHash and result['result'].has_key? 'db' and result['result'].has_key? 'collection' + otherdb = @db.connection[result['result']['db']] + otherdb[result['result']['collection']] + else + @db[result["result"]] + end else raise ArgumentError, "Could not instantiate collection from result. If you specified " + "{:out => {:inline => true}}, then you must also specify :raw => true to get the results."