Method: ActiveRecord::Result#each

Defined in:
activerecord/lib/active_record/result.rb

#each(&block) ⇒ Object

Calls the given block once for each element in row collection, passing row as parameter. Each row is a Hash-like, read only object.

To get real hashes, use .to_a.each.

Returns an Enumerator if no block is given.



128
129
130
131
132
133
134
# File 'activerecord/lib/active_record/result.rb', line 128

def each(&block)
  if block_given?
    hash_rows.each(&block)
  else
    hash_rows.to_enum { @rows.size }
  end
end