Sha256: 6a02c33571bf13c1e0a5ecd57209e61b309930378a984d8197ef2e7078a37030

Contents?: true

Size: 558 Bytes

Versions: 14

Compression:

Stored size: 558 Bytes

Contents

# frozen_string_literal: true

require_relative '../params/current_helper'
require_relative './formatting_helper'

module Sort
  module CurrentDirectionForHelper
    include Params::CurrentHelper
    include Sort::FormattingHelper

    def current_sort_direction_for(attribute, format: :short)
      direction = current_params.dig(:sort, attribute).to_s.downcase

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

      direction
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
actionset-0.11.0 lib/action_set/helpers/sort/current_direction_for_helper.rb
actionset-0.10.0 lib/action_set/helpers/sort/current_direction_for_helper.rb
actionset-0.9.2 lib/action_set/helpers/sort/current_direction_for_helper.rb
actionset-0.9.1 lib/action_set/helpers/sort/current_direction_for_helper.rb
actionset-0.8.2 lib/action_set/helpers/sort/current_direction_for_helper.rb
actionset-0.8.1 lib/action_set/helpers/sort/current_direction_for_helper.rb
actionset-0.8.0 lib/action_set/helpers/sort/current_direction_for_helper.rb
actionset-0.7.0 lib/action_set/helpers/sort/current_direction_for_helper.rb
actionset-0.6.0 lib/action_set/helpers/sort/current_direction_for_helper.rb
actionset-0.5.4 lib/action_set/helpers/sort/current_direction_for_helper.rb
actionset-0.5.3 lib/action_set/helpers/sort/current_direction_for_helper.rb
actionset-0.5.2 lib/action_set/helpers/sort/current_direction_for_helper.rb
actionset-0.5.1 lib/action_set/helpers/sort/current_direction_for_helper.rb
actionset-0.5.0 lib/action_set/helpers/sort/current_direction_for_helper.rb