Module: OrderQuery::Direction
- Defined in:
- lib/order_query/direction.rb
Overview
Responsible for handling :asc and :desc
Constant Summary collapse
- DIRECTIONS =
%i[asc desc].freeze
Class Method Summary collapse
Class Method Details
.all ⇒ Object
10 11 12 |
# File 'lib/order_query/direction.rb', line 10 def all DIRECTIONS end |
.parse!(direction) ⇒ :asc, :desc
23 24 25 26 27 28 |
# File 'lib/order_query/direction.rb', line 23 def parse!(direction) all.include?(direction) && direction or fail ArgumentError, "sort direction must be in #{all.map(&:inspect).join(', ')}, "\ "is #{direction.inspect}" end |
.reverse(direction) ⇒ :asc, :desc
16 17 18 |
# File 'lib/order_query/direction.rb', line 16 def reverse(direction) all[(all.index(direction) + 1) % 2].to_sym end |