Class: SortableColumns::ColumnSorter

Inherits:
Object
  • Object
show all
Defined in:
lib/sortable_columns/column_sorter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource) ⇒ ColumnSorter

Returns a new instance of ColumnSorter.



5
6
7
# File 'lib/sortable_columns/column_sorter.rb', line 5

def initialize(resource)
  @resource = resource
end

Instance Attribute Details

#resourceObject (readonly)

Returns the value of attribute resource.



3
4
5
# File 'lib/sortable_columns/column_sorter.rb', line 3

def resource
  @resource
end

Instance Method Details

#column(column = nil) ⇒ Object



9
10
11
12
# File 'lib/sortable_columns/column_sorter.rb', line 9

def column(column=nil)
  return SortableColumns.config.default_sort_column if column.nil?
  sanitize_column(column) || SortableColumns.config.default_sort_column
end

#direction(direction = nil) ⇒ Object



14
15
16
17
# File 'lib/sortable_columns/column_sorter.rb', line 14

def direction(direction=nil)
  return SortableColumns.config.default_sort_direction if direction.nil?
  sanitize_direction(direction) || SortableColumns.config.default_sort_direction
end