Module: Lipstick::Sortable
- Defined in:
- lib/lipstick/sortable.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- DIRECTIONS =
%w[asc desc].freeze
Class Method Summary collapse
Class Method Details
.direction(direction) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/lipstick/sortable.rb', line 8 def direction(direction) direction = DIRECTIONS.find { |x| x == direction&.downcase } direction ||= DIRECTIONS.first direction end |
.included(base) ⇒ Object
40 41 42 |
# File 'lib/lipstick/sortable.rb', line 40 def self.included(base) base.extend(ClassMethods) end |
.opposite_direction(direction) ⇒ Object
15 16 17 |
# File 'lib/lipstick/sortable.rb', line 15 def opposite_direction(direction) (DIRECTIONS - [direction(direction)]).first end |