Class: AbstractSubreport

Inherits:
Object
  • Object
show all
Defined in:
backend/app/model/reports/abstract_subreport.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent_report) ⇒ AbstractSubreport

Returns a new instance of AbstractSubreport.



13
14
15
16
17
18
# File 'backend/app/model/reports/abstract_subreport.rb', line 13

def initialize(parent_report)
  @repo_id = parent_report.repo_id
  @db = parent_report.db
  @job = parent_report.job
  @format = parent_report.format
end

Instance Attribute Details

#dbObject

Returns the value of attribute db



9
10
11
# File 'backend/app/model/reports/abstract_subreport.rb', line 9

def db
  @db
end

#formatObject

Returns the value of attribute format



11
12
13
# File 'backend/app/model/reports/abstract_subreport.rb', line 11

def format
  @format
end

#jobObject

Returns the value of attribute job



10
11
12
# File 'backend/app/model/reports/abstract_subreport.rb', line 10

def job
  @job
end

#repo_idObject

Returns the value of attribute repo_id



8
9
10
# File 'backend/app/model/reports/abstract_subreport.rb', line 8

def repo_id
  @repo_id
end

Class Method Details

.codeObject



49
50
51
# File 'backend/app/model/reports/abstract_subreport.rb', line 49

def self.code
  self.name.gsub(/(.)([A-Z])/, '\1_\2').downcase
end

.field_nameObject



53
54
55
# File 'backend/app/model/reports/abstract_subreport.rb', line 53

def self.field_name
  raise 'Must specify field_name in order to use in custom report.'
end

.translation_scopeObject



57
58
59
# File 'backend/app/model/reports/abstract_subreport.rb', line 57

def self.translation_scope
  nil
end

Instance Method Details

#codeObject



45
46
47
# File 'backend/app/model/reports/abstract_subreport.rb', line 45

def code
  self.class.code
end

#fix_row(row) ⇒ Object



43
# File 'backend/app/model/reports/abstract_subreport.rb', line 43

def fix_row(row) end

#get_contentObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'backend/app/model/reports/abstract_subreport.rb', line 20

def get_content
  array = []
  query.each do |result|
    row = result.to_hash
    fix_row(row)
    array.push(row)
  end
  if array.empty?
    nil
  else
    array.push(code) if ['pdf', 'html', 'rtf'].include? format
    array
  end
end

#queryObject



35
36
37
# File 'backend/app/model/reports/abstract_subreport.rb', line 35

def query
  db.fetch(query_string)
end

#query_stringObject



39
40
41
# File 'backend/app/model/reports/abstract_subreport.rb', line 39

def query_string
  raise 'Please specify a query string to return your reportable results'
end