Method: Mongoid::Criteria#each
- Defined in:
- lib/mongoid/criteria.rb
#each(&block) ⇒ Object
Iterate over each Document in the results. This can take an optional block to pass to each argument in the results.
Example:
criteria.each { |doc| p doc }
104 105 106 107 108 109 110 |
# File 'lib/mongoid/criteria.rb', line 104 def each(&block) return caching(&block) if cached? if block_given? execute.each { |doc| yield doc } end self end |