Sha256: 66ac7be23c25f4c12159400dcc6dda7b8d35470ae44457f2f32386a69e0f8e9c
Contents?: true
Size: 1.1 KB
Versions: 4
Compression:
Stored size: 1.1 KB
Contents
require 'thread' module Mongoid module Report ScopeCollection = Struct.new(:context) do def initialize(context) @mutex = Mutex.new super end def scopes @scopes ||= modules.map do |key| Scope.new(context, key) end end def query(conditions = {}) scopes.each do |scope| scope.query(conditions) end self end def yield scopes.each do |scope| scope.yield end self end def all {}.tap do |hash| if Mongoid::Report::Config.use_threads_on_aggregate scopes.map do |scope| Thread.new do rows = scope.all @mutex.synchronize do hash[scope.report_name] = rows end end end.map(&:join) else scopes.each do |scope| hash[scope.report_name] = scope.all end end end end private def modules context.settings.keys end end end end
Version data entries
4 entries across 4 versions & 1 rubygems