# File lib/mongoid/contexts/enumerable.rb, line 33 def avg(field) total = sum(field) total ? (total.to_f / count) : nil end