Class: TableSortable::QueryParams
- Inherits:
-
Object
- Object
- TableSortable::QueryParams
- Defined in:
- lib/table_sortable/query_params.rb
Instance Attribute Summary collapse
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#page_size ⇒ Object
readonly
Returns the value of attribute page_size.
Instance Method Summary collapse
-
#initialize(params, columns, column_offset = 0) ⇒ QueryParams
constructor
A new instance of QueryParams.
Constructor Details
#initialize(params, columns, column_offset = 0) ⇒ QueryParams
Returns a new instance of QueryParams.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/table_sortable/query_params.rb', line 5 def initialize(params, columns, column_offset = 0) @page = params[PAGE].to_i @page_size = params[PAGESIZE].to_i # reset column filters and sorters columns.each do |col| col_index = (columns.find_index(col) + column_offset) col.filter.query = params[FCOL] ? params[FCOL][col_index.to_s] : nil col.sorter.sort_order = params[SCOL] && params[SCOL][col_index.to_s] ? ((params[SCOL][col_index.to_s] == SORT_ASC) ? :asc : :desc) : nil end end |
Instance Attribute Details
#page ⇒ Object (readonly)
Returns the value of attribute page.
4 5 6 |
# File 'lib/table_sortable/query_params.rb', line 4 def page @page end |
#page_size ⇒ Object (readonly)
Returns the value of attribute page_size.
4 5 6 |
# File 'lib/table_sortable/query_params.rb', line 4 def page_size @page_size end |