Class: SortableTable::SortColumn

Inherits:
Object
  • Object
show all
Defined in:
lib/sortable_table/models/sort_column.rb

Constant Summary collapse

SORT_DIRECTIONS =
%w(asc desc)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sort_column, sort_direction, options = {}) ⇒ SortColumn

Returns a new instance of SortColumn.



6
7
8
9
10
# File 'lib/sortable_table/models/sort_column.rb', line 6

def initialize(sort_column, sort_direction, options = {})
  @column = sort_column
  @direction = SORT_DIRECTIONS.include?(sort_direction) ? sort_direction : 'asc'
  @order = options[:order] || "#{column} #{direction}"
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



4
5
6
# File 'lib/sortable_table/models/sort_column.rb', line 4

def column
  @column
end

#directionObject (readonly)

Returns the value of attribute direction.



4
5
6
# File 'lib/sortable_table/models/sort_column.rb', line 4

def direction
  @direction
end

#orderObject (readonly)

Returns the value of attribute order.



4
5
6
# File 'lib/sortable_table/models/sort_column.rb', line 4

def order
  @order
end