lib/mongoid/report/attach_proxy.rb in mongoid-report-0.1.9 vs lib/mongoid/report/attach_proxy.rb in mongoid-report-0.2.0
- old
+ new
@@ -1,15 +1,24 @@
module Mongoid
module Report
AttachProxy = Struct.new(:context, :collection, :options) do
- attr_reader :attach_name
+ attr_reader :report_name
def initialize(context, collection, options)
# Lets remove as option because of passing to the next blocks options
- @attach_name = options.delete(:as) || collection
- options = options.merge(attach_name: attach_name, for: collection)
+ report_name = options.delete(:as)
+
+ if collection
+ report_name ||= Collections.name(collection)
+ end
+
+ options.merge!(
+ report_name: report_name,
+ collection: collection,
+ )
+
super(context, collection, options)
end
def columns(*fields)
proxy_options = fields.extract_options!
@@ -33,13 +42,25 @@
proxy_options = fields.extract_options!
proxy_options.merge!(options)
context.group_by(*fields, proxy_options)
end
- def filter(*fields)
+ def match(*fields)
proxy_options = fields.extract_options!
proxy_options.merge!(options)
- context.filter(*fields, proxy_options)
+ context.match(*fields, proxy_options)
+ end
+
+ def query(*fields)
+ proxy_options = fields.extract_options!
+ proxy_options.merge!(options)
+ context.query(*fields, proxy_options)
+ end
+
+ def batches(*fields)
+ proxy_options = fields.extract_options!
+ proxy_options.merge!(options)
+ context.batches(*fields, proxy_options)
end
end
end
end