module Sort::NextDirectionForHelper

Public Instance Methods

next_sort_direction_for(attribute, format: :short) click to toggle source
# 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