Sha256: d24d0029563b75f720aeacc824430e6f543e6e7050bef8262ad7f03791aafc5a

Contents?: true

Size: 665 Bytes

Versions: 7

Compression:

Stored size: 665 Bytes

Contents

# frozen_string_literal: true

require_relative './current_direction_for_helper'
require_relative './formatting_helper'

module Sort
  module NextDirectionForHelper
    include Sort::CurrentDirectionForHelper
    include Sort::FormattingHelper

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

      return ascending_str(format) unless direction.presence_in %w[asc desc ascending descending]
      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
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
actionset-0.7.0 lib/action_set/helpers/sort/next_direction_for_helper.rb
actionset-0.6.0 lib/action_set/helpers/sort/next_direction_for_helper.rb
actionset-0.5.4 lib/action_set/helpers/sort/next_direction_for_helper.rb
actionset-0.5.3 lib/action_set/helpers/sort/next_direction_for_helper.rb
actionset-0.5.2 lib/action_set/helpers/sort/next_direction_for_helper.rb
actionset-0.5.1 lib/action_set/helpers/sort/next_direction_for_helper.rb
actionset-0.5.0 lib/action_set/helpers/sort/next_direction_for_helper.rb