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 ⇒ void
- #success? ⇒ Boolean
- #to_smart_services_by_rep_csv ⇒ String?
- #to_smart_services_by_report_grouping_csv ⇒ String?
Instance Method Details
#execute ⇒ void
This method returns an undefined value.
13 14 15 16 17 |
# File 'app/models/report/smart_services/smart_services_command.rb', line 13 def execute return unless valid? @result = Report::SmartServices::SmartServices.result(attributes) end |
#success? ⇒ Boolean
52 53 54 |
# File 'app/models/report/smart_services/smart_services_command.rb', line 52 def success? valid? && @result.success? end |
#to_smart_services_by_rep_csv ⇒ String?
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/models/report/smart_services/smart_services_command.rb', line 36 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 ⇒ String?
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/models/report/smart_services/smart_services_command.rb', line 20 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 |