Class: TrueandcoAnalytics::Reports

Inherits:
Object
  • Object
show all
Extended by:
Modules::Info
Defined in:
lib/trueandco_analytics/common/services/reports.rb

Class Method Summary collapse

Methods included from Modules::Info

error_message, info, result

Class Method Details

.available_formatsObject



10
11
12
# File 'lib/trueandco_analytics/common/services/reports.rb', line 10

def self.available_formats
  TrueandcoAnalytics::ApplicationReport.formats
end

.available_reportsObject



5
6
7
8
# File 'lib/trueandco_analytics/common/services/reports.rb', line 5

def self.available_reports
  Dir["#{COMMON_PATH}/reports/*.rb"].each { |f| require f }
  TrueandcoAnalytics::ApplicationReport.reports
end

.get_report_obj(report_name, format = nil, datetime_start = nil, datetime_end = nil) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/trueandco_analytics/common/services/reports.rb', line 14

def self.get_report_obj(report_name, format = nil, datetime_start = nil, datetime_end = nil)
  unless self.available_reports.include? report_name
    raise ArgumentError, I18n.t("trueandco_analytics.error.argument.unknown_report")
  end
  Object.const_get("TrueandcoAnalytics::#{report_name.camelize}").new(format, datetime_start, datetime_end)
rescue ArgumentError => e
  error_message(e.message)
rescue StandardError => e
  error_message(e.message)
end