Class: Dossier::Report

Inherits:
Object
  • 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

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/dossier/report.rb', line 8

def options
  @options
end

#parentObject

Returns the value of attribute parent.



9
10
11
# File 'lib/dossier/report.rb', line 9

def parent
  @parent
end

Class Method Details

.filenameObject



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

Returns:

  • (Boolean)


62
63
64
# File 'lib/dossier/report.rb', line 62

def display_column?(column)
  true
end

#dossier_clientObject



66
67
68
# File 'lib/dossier/report.rb', line 66

def dossier_client
  Dossier.client
end

#format_column(column, value) ⇒ Object



58
59
60
# File 'lib/dossier/report.rb', line 58

def format_column(column, value)
  value
end

#format_header(header) ⇒ Object



54
55
56
# File 'lib/dossier/report.rb', line 54

def format_header(header)
  formatter.titleize(header.to_s)
end

#queryObject



35
36
37
38
# File 'lib/dossier/report.rb', line 35

def query
  build_query unless defined?(@query)
  @query.to_s
end

#raw_resultsObject



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

#rendererObject



70
71
72
# File 'lib/dossier/report.rb', line 70

def renderer
  @renderer ||= Renderer.new(self)
end

#resultsObject



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

#runObject



50
51
52
# File 'lib/dossier/report.rb', line 50

def run
  tap { execute }
end

#sqlObject

Raises:

  • (NotImplementedError)


31
32
33
# File 'lib/dossier/report.rb', line 31

def sql
  raise NotImplementedError, "`sql` method must be defined by each report"
end