Module: Sort::NextDirectionForHelper

Includes:
CurrentDirectionForHelper, FormattingHelper
Included in:
DescriptionForHelper, PathForHelper
Defined in:
lib/action_set/helpers/sort/next_direction_for_helper.rb

Instance Method Summary collapse

Methods included from FormattingHelper

#ascending_str, #descending_str

Methods included from CurrentDirectionForHelper

#current_sort_direction_for

Methods included from Params::CurrentHelper

#current_params

Instance Method Details

#next_sort_direction_for(attribute, format: :short) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/action_set/helpers/sort/next_direction_for_helper.rb', line 11

def next_sort_direction_for(attribute, format: :short)
  direction = current_sort_direction_for(attribute)

  return ascending_str(format) if direction.presence_in %w[desc descending]
  return descending_str(format) if direction.presence_in %w[asc ascending]

  ascending_str(format)
end