class Right::RansackableFilter

Attributes

app[R]

Public Class Methods

new(app) click to toggle source

@param app [#call]

# File lib/right/ransackable_filter.rb, line 6
def initialize(app)
  @app = app
end

Public Instance Methods

call(env) click to toggle source

@param env [<ActiveRecord::Relation, Hash]

* first element is a scope to be filtered
* second is a hash with user provided filters

@return [<ActiveRecord::Relation, Hash]

# File lib/right/ransackable_filter.rb, line 15
def call(env)
  scope, params = env
  filtered_scope = scope.ransack(params[:filter]).result
  app.call([filtered_scope, params])
end