fixed nasty bug in reportable method - reportable - Fork of reportable required by WarVox, from hdm/reportable.
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) commit df7c7ca085006ff962614940938e9212569aa0c8
(DIR) parent 24e48d964ab4740114cb93438a8158278227f42f
(HTM) Author: Marco Otte-Witte <marco.otte-witte@simplabs.com>
Date: Thu, 11 Mar 2010 21:27:18 +0100
fixed nasty bug in reportable method
Diffstat:
M lib/saulabs/reportable.rb | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
---
(DIR) diff --git a/lib/saulabs/reportable.rb b/lib/saulabs/reportable.rb
@@ -44,14 +44,15 @@ module Saulabs
# end
def reportable(name, options = {})
(class << self; self; end).instance_eval do
- define_method "#{name.to_s}_report".to_sym do |*args|
- if options.delete(:cumulate)
- report = Saulabs::Reportable::CumulatedReport.new(self, name, options)
- else
- report = Saulabs::Reportable::Report.new(self, name, options)
- end
- raise ArgumentError.new unless args.length == 0 || (args.length == 1 && args[0].is_a?(Hash))
- report.run(args.length == 0 ? {} : args[0])
+ report_klass = if options.delete(:cumulate)
+ Saulabs::Reportable::CumulatedReport
+ else
+ Saulabs::Reportable::Report
+ end
+ define_method("#{name.to_s}_report".to_sym) do |*args|
+ report = report_klass.new(self, name, options)
+ raise ArgumentError.new unless args.empty? || (args.length == 1 && args.first.is_a?(Hash))
+ report.run(args.first || {})
end
end
end