class Might::RansackableSortParametersAdapter

Converts array of parameters to hash familiar to ransack gem

Attributes

app[R]

Public Class Methods

new(app) click to toggle source
# File lib/might/ransackable_sort_parameters_adapter.rb, line 6
def initialize(app)
  @app = app
end

Public Instance Methods

call(env) click to toggle source
# File lib/might/ransackable_sort_parameters_adapter.rb, line 10
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