Skip to content

Commit

Permalink
Support :db key for :out in map_reduce
Browse files Browse the repository at this point in the history
References RUBY-389
  • Loading branch information
johnewart committed Dec 15, 2011
1 parent 4858d30 commit 28796ac
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/mongo/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,12 @@ def map_reduce(map, reduce, opts={})
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."
Expand Down

0 comments on commit 28796ac

Please sign in to comment.