Module: Tabloid::Report::InstanceMethods
- Defined in:
- lib/tabloid/report.rb
Instance Method Summary collapse
- #cache_key ⇒ Object
- #data ⇒ Object
- #parameter(key) ⇒ Object
- #parameters ⇒ Object
- #prepare(options = {}) ⇒ Object
- #report_columns ⇒ Object
- #to_csv ⇒ Object
- #to_html ⇒ Object
Instance Method Details
#cache_key ⇒ Object
117 118 119 120 121 122 123 124 125 |
# File 'lib/tabloid/report.rb', line 117 def cache_key @key ||= begin if self.class.cache_key_block self.instance_exec &self.class.cache_key_block else nil end end end |
#data ⇒ Object
103 104 105 106 107 |
# File 'lib/tabloid/report.rb', line 103 def data load_from_cache if Tabloid.cache_enabled? build_and_cache_data @data end |
#parameter(key) ⇒ Object
98 99 100 101 |
# File 'lib/tabloid/report.rb', line 98 def parameter(key) load_from_cache if Tabloid.cache_enabled? @report_parameters[key] if @report_parameters end |
#parameters ⇒ Object
94 95 96 |
# File 'lib/tabloid/report.rb', line 94 def parameters self.class.parameters end |
#prepare(options = {}) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/tabloid/report.rb', line 76 def prepare(={}) before_prepare if self.respond_to?(:before_prepare) @report_parameters = {} parameters.each do |param| value = .delete param.key raise Tabloid::MissingParameterError.new("Must supply :#{param.key} when creating the report") unless value @report_parameters[param.key] = value end data after_prepare if self.respond_to?(:after_prepare) self end |
#report_columns ⇒ Object
90 91 92 |
# File 'lib/tabloid/report.rb', line 90 def report_columns self.class.report_columns end |
#to_csv ⇒ Object
113 114 115 |
# File 'lib/tabloid/report.rb', line 113 def to_csv data.to_csv end |
#to_html ⇒ Object
109 110 111 |
# File 'lib/tabloid/report.rb', line 109 def to_html "<table>#{data.to_html}</table>" end |