Class: Dossier::Report
- Inherits:
-
Object
show all
- Includes:
- ActiveSupport::Callbacks, Model
- Defined in:
- lib/dossier/report.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Model
anonymous_report, class_to_name, included, name_to_class, #persisted?, #to_key, #to_model, #to_s
Constructor Details
#initialize(options = {}) ⇒ Report
Returns a new instance of Report.
27
28
29
|
# File 'lib/dossier/report.rb', line 27
def initialize(options = {})
@options = options.dup.with_indifferent_access
end
|
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
8
9
10
|
# File 'lib/dossier/report.rb', line 8
def options
@options
end
|
#parent ⇒ Object
Returns the value of attribute parent.
9
10
11
|
# File 'lib/dossier/report.rb', line 9
def parent
@parent
end
|
Class Method Details
.filename ⇒ Object
23
24
25
|
# File 'lib/dossier/report.rb', line 23
def self.filename
"#{report_name.parameterize}-report_#{Time.now.strftime('%Y-%m-%d_%H-%M-%S-%Z')}"
end
|
.inherited(base) ⇒ Object
18
19
20
21
|
# File 'lib/dossier/report.rb', line 18
def self.inherited(base)
super
base.template = base.report_name
end
|
Instance Method Details
#display_column?(column) ⇒ Boolean
62
63
64
|
# File 'lib/dossier/report.rb', line 62
def display_column?(column)
true
end
|
#dossier_client ⇒ Object
66
67
68
|
# File 'lib/dossier/report.rb', line 66
def dossier_client
Dossier.client
end
|
58
59
60
|
# File 'lib/dossier/report.rb', line 58
def format_column(column, value)
value
end
|
54
55
56
|
# File 'lib/dossier/report.rb', line 54
def ()
formatter.titleize(.to_s)
end
|
#query ⇒ Object
35
36
37
38
|
# File 'lib/dossier/report.rb', line 35
def query
build_query unless defined?(@query)
@query.to_s
end
|
#raw_results ⇒ Object
45
46
47
48
|
# File 'lib/dossier/report.rb', line 45
def raw_results
execute unless query_results
@raw_results ||= Result::Unformatted.new(query_results, self)
end
|
#renderer ⇒ Object
70
71
72
|
# File 'lib/dossier/report.rb', line 70
def renderer
@renderer ||= Renderer.new(self)
end
|
#results ⇒ Object
40
41
42
43
|
# File 'lib/dossier/report.rb', line 40
def results
execute unless query_results
@results ||= Result::Formatted.new(query_results, self)
end
|
#run ⇒ Object
50
51
52
|
# File 'lib/dossier/report.rb', line 50
def run
tap { execute }
end
|
#sql ⇒ Object
31
32
33
|
# File 'lib/dossier/report.rb', line 31
def sql
raise NotImplementedError, "`sql` method must be defined by each report"
end
|