Class: AbstractSubreport
- Inherits:
-
Object
- Object
- AbstractSubreport
- Includes:
- CustomField::Mixin
- Defined in:
- backend/app/model/reports/abstract_subreport.rb
Instance Attribute Summary collapse
-
#db ⇒ Object
Returns the value of attribute db.
-
#format ⇒ Object
Returns the value of attribute format.
-
#job ⇒ Object
Returns the value of attribute job.
-
#repo_id ⇒ Object
Returns the value of attribute repo_id.
Class Method Summary collapse
Instance Method Summary collapse
-
#code ⇒ Object
-
#fix_row(row) ⇒ Object
-
#get_content ⇒ Object
-
#initialize(parent_report) ⇒ AbstractSubreport
constructor
A new instance of AbstractSubreport.
-
#query ⇒ Object
-
#query_string ⇒ Object
Methods included from CustomField::Mixin
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
#db ⇒ Object
Returns the value of attribute db
9 10 11 |
# File 'backend/app/model/reports/abstract_subreport.rb', line 9 def db @db end |
#format ⇒ Object
Returns the value of attribute format
11 12 13 |
# File 'backend/app/model/reports/abstract_subreport.rb', line 11 def format @format end |
#job ⇒ Object
Returns the value of attribute job
10 11 12 |
# File 'backend/app/model/reports/abstract_subreport.rb', line 10 def job @job end |
#repo_id ⇒ Object
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
.code ⇒ Object
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_name ⇒ Object
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_scope ⇒ Object
57 58 59 |
# File 'backend/app/model/reports/abstract_subreport.rb', line 57 def self.translation_scope nil end |
Instance Method Details
#code ⇒ Object
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_content ⇒ Object
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 |
#query ⇒ Object
35 36 37 |
# File 'backend/app/model/reports/abstract_subreport.rb', line 35 def query db.fetch(query_string) end |
#query_string ⇒ Object
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 |