Method: ReportFilter#initialize
- Defined in:
- app/models/report_filter.rb
#initialize(attributes) ⇒ ReportFilter
Returns a new instance of ReportFilter.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/models/report_filter.rb', line 7 def initialize(attributes) date = Date.today - 5 @start_on = Date.civil(date.year, date.month, 01) @end_on = Date.civil(date.year, date.month, -1) @page_size = 1000 if attributes attributes = attributes.clone start_on_param = attributes.delete(:start_on) @start_on = Date.parse(start_on_param) if start_on_param && start_on_param.size > 0 end_on_param = attributes.delete(:end_on) @end_on = Date.parse(end_on_param) if end_on_param && end_on_param.size > 0 page_size_param = attributes.delete(:page_size) @page_size = page_size_param.to_i if page_size_param.to_i > 0 raise "Unknown parameters: #{attributes.inspect}" unless attributes.empty? end end |