Sha256: 5ccbbc3ccbfd6b4d3576de1cfafa89295518c4e1d8f2b338e4123dd96ac4b73a

Contents?: true

Size: 567 Bytes

Versions: 7

Compression:

Stored size: 567 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) 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.11.0 lib/action_set/helpers/sort/next_direction_for_helper.rb
actionset-0.10.0 lib/action_set/helpers/sort/next_direction_for_helper.rb
actionset-0.9.2 lib/action_set/helpers/sort/next_direction_for_helper.rb
actionset-0.9.1 lib/action_set/helpers/sort/next_direction_for_helper.rb
actionset-0.8.2 lib/action_set/helpers/sort/next_direction_for_helper.rb
actionset-0.8.1 lib/action_set/helpers/sort/next_direction_for_helper.rb
actionset-0.8.0 lib/action_set/helpers/sort/next_direction_for_helper.rb