Class: Pragma::Operation::Index
- Inherits:
-
Base
- Object
- Base
- Pragma::Operation::Index
- Defined in:
- lib/pragma/operation/index.rb
Overview
Finds all records of the requested resource, authorizes them, paginates them and decorates them.
Instance Method Summary collapse
- #include!(options) ⇒ Object
- #respond!(options) ⇒ Object
- #retrieve!(options) ⇒ Object
-
#scope!(options, model:) ⇒ Object
TODO: Turn this into a macro.
Instance Method Details
#include!(options) ⇒ Object
22 23 24 25 26 |
# File 'lib/pragma/operation/index.rb', line 22 def include!() ['model'] = AssociationIncluder .load_adaptor(['model']) .include_associations(['params'][:expand] || []) end |
#respond!(options) ⇒ Object
36 37 38 39 40 |
# File 'lib/pragma/operation/index.rb', line 36 def respond!(, **) ['result.response'] = Response::Ok.new( entity: ['result.decorator.collection'] ) end |
#retrieve!(options) ⇒ Object
18 19 20 |
# File 'lib/pragma/operation/index.rb', line 18 def retrieve!() ['model'] = ['model.class'].all end |
#scope!(options, model:) ⇒ Object
TODO: Turn this into a macro.
29 30 31 32 33 34 |
# File 'lib/pragma/operation/index.rb', line 29 def scope!(, model:, **) ['model'] = ['policy.default.scope.class'].new( ['policy.context'] || ['current_user'], model ).resolve end |