Sha256: 7f4af42b5dd5e240944cdd14344b5d03ccce2d9cea8ffe55779d871108844bb2

Contents?: true

Size: 472 Bytes

Versions: 9

Compression:

Stored size: 472 Bytes

Contents

module Might
  # Converts array of parameters to hash familiar to ransack gem
  #
  class RansackableSortParametersAdapter
    def initialize(app)
      @app = app
    end

    def call(env)
      scope, params = env

      ransackable_parameters = Array(params[:sort]).map do |parameter|
        "#{parameter.name} #{parameter.direction}"
      end

      app.call([scope, params.merge(sort: ransackable_parameters)])
    end

    private

    attr_reader :app
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
might-0.7.1 lib/might/ransackable_sort_parameters_adapter.rb
might-0.7.0 lib/might/ransackable_sort_parameters_adapter.rb
might-0.6.0 lib/might/ransackable_sort_parameters_adapter.rb
might-0.5.2 lib/might/ransackable_sort_parameters_adapter.rb
might-0.5.1 lib/might/ransackable_sort_parameters_adapter.rb
might-0.5.0 lib/might/ransackable_sort_parameters_adapter.rb
might-0.4.0 lib/might/ransackable_sort_parameters_adapter.rb
might-0.3.1 lib/might/ransackable_sort_parameters_adapter.rb
might-0.3.0 lib/might/ransackable_sort_parameters_adapter.rb