You want the common ActiveRecord method find_each
for this use case (and for other datastores). For example:
MyModeal.find_each {|object| do_something(object) }
Behind the scenes, MongoMapper is issuing a MongoDB find
which returns an enumerable cursor. The find_each
method will iterate through the cursor, yielding one MongoMapper object at a time.