Module: QueryReport::Record
- Included in:
- Report
- Defined in:
- lib/query_report/record.rb
Instance Attribute Summary collapse
-
#query ⇒ Object
Returns the value of attribute query.
Instance Method Summary collapse
- #all_records ⇒ Object
- #apply ⇒ Object
- #filtered_query ⇒ Object
- #map_record(query, render_from_view) ⇒ Object
- #model_class ⇒ Object
- #paginated_query ⇒ Object
- #records ⇒ Object
- #search ⇒ Object
Instance Attribute Details
#query ⇒ Object
Returns the value of attribute query.
3 4 5 |
# File 'lib/query_report/record.rb', line 3 def query @query end |
Instance Method Details
#all_records ⇒ Object
33 34 35 |
# File 'lib/query_report/record.rb', line 33 def all_records @all_records ||= map_record(filtered_query, false) end |
#apply ⇒ Object
24 25 26 27 |
# File 'lib/query_report/record.rb', line 24 def apply @filtered_query ||= apply_filters(query.clone, @params) @paginated_query ||= apply_pagination(@filtered_query, @params) end |
#filtered_query ⇒ Object
9 10 11 12 |
# File 'lib/query_report/record.rb', line 9 def filtered_query apply @filtered_query end |
#map_record(query, render_from_view) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/query_report/record.rb', line 37 def map_record(query, render_from_view) @columns = @columns.delete_if { |col| col.only_on_web? } unless render_from_view query.map do |record| array = @columns.collect { |column| [column.humanize, column.value(record)] } Hash[*array.flatten] end end |
#model_class ⇒ Object
5 6 7 |
# File 'lib/query_report/record.rb', line 5 def model_class query.klass end |
#paginated_query ⇒ Object
14 15 16 17 |
# File 'lib/query_report/record.rb', line 14 def paginated_query apply @paginated_query end |
#records ⇒ Object
29 30 31 |
# File 'lib/query_report/record.rb', line 29 def records @records ||= map_record(paginated_query, true) end |
#search ⇒ Object
19 20 21 22 |
# File 'lib/query_report/record.rb', line 19 def search apply @search end |