diff --git a/lib/mongo/cursor.rb b/lib/mongo/cursor.rb index ed7efd9..61c0ce6 100644 --- a/lib/mongo/cursor.rb +++ b/lib/mongo/cursor.rb @@ -71,6 +71,11 @@ module Mongo doc end + def next_object + warn "Cursor#next_object is deprecated; please use Cursor#next_document instead." + next_document + end + # Get the size of the result set for this query. # # Returns the number of objects in the result set for this query. Does diff --git a/test/test_cursor.rb b/test/test_cursor.rb index e34d4ff..198622e 100644 --- a/test/test_cursor.rb +++ b/test/test_cursor.rb @@ -58,6 +58,13 @@ class CursorTest < Test::Unit::TestCase assert_equal 0, @@db['acollectionthatdoesn'].count() end + def test_next_object_deprecation + @@coll.remove + @@coll.insert({"a" => 1}) + + assert_equal 1, @@coll.find().next_object["a"] + end + def test_sort @@coll.remove 5.times{|x| @@coll.insert({"a" => x}) }