reportable 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/HISTORY.md CHANGED
@@ -1,3 +1,8 @@
1
+ v1.0.3
2
+ ------
3
+
4
+ * Fixed bug in reportable method that broke cumulated reports and reports with options
5
+
1
6
  v1.0.2
2
7
  ------
3
8
 
data/README.md CHANGED
@@ -22,7 +22,7 @@ the number of updated users records per second or the number of registrations of
22
22
 
23
23
  reportable :last_name_starting_with_a_registrations, :aggregation => :count, :grouping => :month, :conditions => ["last_name LIKE 'A%'"]
24
24
 
25
- reportable :updated_per_second, :aggregation => :count, :grouping => :second, :date_column => :updated_at
25
+ reportable :updated_per_second, :aggregation => :count, :grouping => :hour, :date_column => :updated_at
26
26
 
27
27
  end
28
28
 
@@ -44,14 +44,15 @@ module Saulabs
44
44
  # end
45
45
  def reportable(name, options = {})
46
46
  (class << self; self; end).instance_eval do
47
- define_method "#{name.to_s}_report".to_sym do |*args|
48
- if options.delete(:cumulate)
49
- report = Saulabs::Reportable::CumulatedReport.new(self, name, options)
50
- else
51
- report = Saulabs::Reportable::Report.new(self, name, options)
52
- end
53
- raise ArgumentError.new unless args.length == 0 || (args.length == 1 && args[0].is_a?(Hash))
54
- report.run(args.length == 0 ? {} : args[0])
47
+ report_klass = if options.delete(:cumulate)
48
+ Saulabs::Reportable::CumulatedReport
49
+ else
50
+ Saulabs::Reportable::Report
51
+ end
52
+ define_method("#{name.to_s}_report".to_sym) do |*args|
53
+ report = report_klass.new(self, name, options)
54
+ raise ArgumentError.new unless args.empty? || (args.length == 1 && args.first.is_a?(Hash))
55
+ report.run(args.first || {})
55
56
  end
56
57
  end
57
58
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reportable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marco Otte-Witte