Class: Report::SmartServices::SmartServicesCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- Report::SmartServices::SmartServicesCommand
- Defined in:
- app/models/report/smart_services/smart_services_command.rb
Overview
Helper class scoped to Report::SmartServices.
Instance Method Summary collapse
- #execute ⇒ Object
- #success? ⇒ Boolean
- #to_smart_services_by_rep_csv ⇒ Object
- #to_smart_services_by_report_grouping_csv ⇒ Object
Instance Method Details
#execute ⇒ Object
11 12 13 14 15 |
# File 'app/models/report/smart_services/smart_services_command.rb', line 11 def execute return unless valid? @result = Report::SmartServices::SmartServices.result(attributes) end |
#success? ⇒ Boolean
47 48 49 |
# File 'app/models/report/smart_services/smart_services_command.rb', line 47 def success? valid? && @result.success? end |
#to_smart_services_by_rep_csv ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/models/report/smart_services/smart_services_command.rb', line 32 def to_smart_services_by_rep_csv return unless valid? @result = Report::SmartServices::SmartServices.result(attributes) return if @result.smart_services_data_breakdown_by_rep.blank? attributes = @result.smart_services_data_breakdown_by_rep.first.keys CSV.generate(headers: true) do |csv| csv << attributes @result.smart_services_data_breakdown_by_rep.each do |r| csv << r end end end |
#to_smart_services_by_report_grouping_csv ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/models/report/smart_services/smart_services_command.rb', line 17 def to_smart_services_by_report_grouping_csv return unless valid? @result = Report::SmartServices::SmartServices.result(attributes) return if @result.smart_services_data_breakdown.blank? attributes = @result.smart_services_data_breakdown.first.keys CSV.generate(headers: true) do |csv| csv << attributes @result.smart_services_data_breakdown.each do |r| csv << r end end end |