Sha256: 936e7a33733ad2fd51cbc8c9b152e677895dc3948085a60fa81379a0c21396ce

Contents?: true

Size: 677 Bytes

Versions: 3

Compression:

Stored size: 677 Bytes

Contents

module Trax
  module Controller
    module Collection
      module Sortable
        extend ::ActiveSupport::Concern

        SORT_DIRECTIONS = [ "asc", "desc" ].freeze

        module ClassMethods
          def has_sort_scope(sort_scope_name, only: [:index, :search], type: :boolean, **options)
            SORT_DIRECTIONS.each do |dir|
              _sort_scope_name = :"#{sort_scope_name}_#{dir}"
              has_scope(_sort_scope_name, only: only, type: type, **options)
            end
          end

          def has_sort_scopes(*names, **options)
            names.each{ |_name| has_sort_scope(_name, **options) }
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
trax_controller-1.0.0 lib/trax/controller/collection/sortable.rb
trax_controller-0.1.4 lib/trax/controller/collection/sortable.rb
trax_controller-0.1.3 lib/trax/controller/collection/sortable.rb