lib/mongoid/report/collection.rb in mongoid-report-0.1.5 vs lib/mongoid/report/collection.rb in mongoid-report-0.1.6
- old
+ new
@@ -19,10 +19,15 @@
end
def summary
@summary ||= reduce(Hash.new{|h, k| h[k] = 0}) do |summary, row|
@fields.each do |field|
+ next if @columns.has_key?(field.to_s)
summary[field] += row[field.to_s]
+ end
+
+ @columns.each do |name, function|
+ summary[name] = function.call(@context, row)
end
summary
end.with_indifferent_access
end