Class: Might::RansackableFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/might/ransackable_filter.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ RansackableFilter



6
7
8
# File 'lib/might/ransackable_filter.rb', line 6

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ <ActiveRecord::Relation, Hash]



15
16
17
18
19
# File 'lib/might/ransackable_filter.rb', line 15

def call(env)
  scope, params = env
  filtered_scope = scope.ransack(params[:filter]).result
  app.call([filtered_scope, params])
end