Sha256: 346ab76a75e824d4ef74b2548fea925429b0a8f1aa5f988ba2247eff27e09f05

Contents?: true

Size: 671 Bytes

Versions: 3

Compression:

Stored size: 671 Bytes

Contents

require 'securerandom'

module Mongoid
  module Report

    ReportProxy = Struct.new(:context, :name) do
      def attach_proxy
        @attach_proxy ||= begin
          AttachProxy.new(context, nil, report_module: name)
        end
      end
      delegate :column, :columns, :mapping, :group_by, :match,
        :batches, :query, to: :attach_proxy

      def attach_to(*fields, &block)
        options = fields.extract_options!
        model   = fields[0]

        report_name = options.delete(:as) || Collections.name(model)
        options.merge!(report_module: name, as: report_name)

        context.attach_to(*fields, options, &block)
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mongoid-report-0.2.2 lib/mongoid/report/report_proxy.rb
mongoid-report-0.2.1 lib/mongoid/report/report_proxy.rb
mongoid-report-0.2.0 lib/mongoid/report/report_proxy.rb