module Lipstick::Sortable::ClassMethods

Attributes

sortable_by_cases[R]
sortable_by_else[R]

Public Instance Methods

sortable_by(sort_cases, sort_else) click to toggle source
# File lib/lipstick/sortable.rb, line 23
def sortable_by(sort_cases, sort_else)
  @sortable_by_cases = sort_cases
  @sortable_by_else = sort_else
end
sortable_sort(sort_by, direction) click to toggle source
# File lib/lipstick/sortable.rb, line 28
def sortable_sort(sort_by, direction)
  sort_by = sort_by&.to_sym
  direction = Lipstick::Sortable.direction(direction)

  if sort_by && sortable_by_cases.key?(sort_by)
    sortable_by_cases[sort_by].call(direction)
  else
    sortable_by_else.call(direction)
  end
end