Sha256: 8c9882dd12407ce90103740beb453cbb00dd77f95d62d6407991bb8373a5e3ca

Contents?: true

Size: 665 Bytes

Versions: 7

Compression:

Stored size: 665 Bytes

Contents

module Mongoid
  module Report

    ScopeCollection = Struct.new(:context) do
      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
        scopes.inject({}) do |hash, scope|
          hash[scope.report_name] = scope.all
          hash
        end
      end

      private

      def modules
        context.settings.keys
      end
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mongoid-report-0.1.3 lib/mongoid/report/scope_collection.rb
mongoid-report-0.1.2 lib/mongoid/report/scope_collection.rb
mongoid-report-0.1.1 lib/mongoid/report/scope_collection.rb
mongoid-report-0.1.0 lib/mongoid/report/scope_collection.rb
mongoid-report-0.0.11 lib/mongoid/report/scope_collection.rb
mongoid-report-0.0.10 lib/mongoid/report/scope_collection.rb
mongoid-report-0.0.9 lib/mongoid/report/scope_collection.rb