Module: QueryReport::ColumnModule
- Included in:
- Report
- Defined in:
- lib/query_report/column.rb
Defined Under Namespace
Classes: Column
Instance Attribute Summary collapse
-
#columns ⇒ Object
Returns the value of attribute columns.
Instance Method Summary collapse
-
#column(name, options = {}, &block) ⇒ Object
Creates a filter and adds to the filters If you want to sort a column which is a column of the active record model that the query returns, then just set true to make the column sortable.
- #column_total_with_colspan ⇒ Object
Instance Attribute Details
#columns ⇒ Object
Returns the value of attribute columns.
8 9 10 |
# File 'lib/query_report/column.rb', line 8 def columns @columns end |
Instance Method Details
#column(name, options = {}, &block) ⇒ Object
Creates a filter and adds to the filters If you want to sort a column which is a column of the active record model that the query returns, then just set true to make the column sortable. If the column is from another table then you have to specify the column name.
57 58 59 |
# File 'lib/query_report/column.rb', line 57 def column(name, ={}, &block) @columns << Column.new(self, name, , block) end |
#column_total_with_colspan ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/query_report/column.rb', line 61 def column_total_with_colspan total_with_colspan = [] colspan = 0 total_text_printed = false columns.each do |column| if column.has_total? if colspan > 0 title = total_text_printed ? '' : I18n.t('query_report.total') total_with_colspan << (colspan == 1 ? {content: title} : {content: title, colspan: colspan}) end total_with_colspan << {content: column.total, align: column.align} total_text_printed = true colspan = 0 else colspan += 1 end end if colspan > 0 total_with_colspan << {content: '', colspan: colspan} end total_with_colspan end |