Sha256: 922d8bbc055f4e97e7a11ce4a8b198305e54aa082f5d3d161199bb6b3e2729be
Contents?: true
Size: 822 Bytes
Versions: 1
Compression:
Stored size: 822 Bytes
Contents
module Mongoid module Report Scope = Struct.new(:context, :report_name) do def query(conditions) queries.concat([conditions]) self end # We need to add grouping conditions when user needs it. def yield return self if @yielded queries.concat(context.queries(report_name)) @yielded = true self end def all self.yield unless yielded? Collection.new(klass.collection.aggregate(queries), fields) end private def yielded? @yielded end def queries @queries ||= [] end def klass context.class.settings_property(report_name, :for) end def fields context.class.settings_property(report_name, :fields) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mongoid-report-0.0.7 | lib/mongoid/report/scope.rb |