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