Sha256: 95ffe944c8f37bf943b52e6a1e943c34d2e11cc6871638e6e1e3368e1e7e2ce4
Contents?: true
Size: 852 Bytes
Versions: 3
Compression:
Stored size: 852 Bytes
Contents
module Mongoid module Report Scope = Struct.new(:context, :report_name) do def query(conditions = {}) queries.concat([conditions]) unless conditions.empty? 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mongoid-report-0.0.10 | lib/mongoid/report/scope.rb |
mongoid-report-0.0.9 | lib/mongoid/report/scope.rb |
mongoid-report-0.0.8 | lib/mongoid/report/scope.rb |