Class: TableSortable::QueryParams

Inherits:
Object
  • Object
show all
Defined in:
lib/table_sortable/query_params.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#pageObject (readonly)

Returns the value of attribute page.



4
5
6
# File 'lib/table_sortable/query_params.rb', line 4

def page
  @page
end

#page_sizeObject (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