Class: Might::SortMiddleware
- Inherits:
-
Object
- Object
- Might::SortMiddleware
- Defined in:
- lib/might/sort_middleware.rb
Overview
Sort scope using ransack gem
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
Instance Method Summary collapse
-
#call(env) ⇒ Object
First argument is a ActiveRecord relation which must be sorted Second argument is a request parameters provided by user.
-
#initialize(app) ⇒ SortMiddleware
constructor
A new instance of SortMiddleware.
Constructor Details
#initialize(app) ⇒ SortMiddleware
Returns a new instance of SortMiddleware.
12 13 14 |
# File 'lib/might/sort_middleware.rb', line 12 def initialize(app) @app = app end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
16 17 18 |
# File 'lib/might/sort_middleware.rb', line 16 def app @app end |
Instance Method Details
#call(env) ⇒ Object
First argument is a ActiveRecord relation which must be sorted Second argument is a request parameters provided by user
22 23 24 25 26 27 28 29 |
# File 'lib/might/sort_middleware.rb', line 22 def call(env) scope, = ::Middleware::Builder.new do |b| b.use RansackableSortParametersAdapter b.use RansackableSort end.call(env) app.call([scope, env[1]]) end |