Sha256: ed418beb765e81d1f29fb4bf501de7b4b9e5b8934686d4e3e5d93539330940ff
Contents?: true
Size: 971 Bytes
Versions: 2
Compression:
Stored size: 971 Bytes
Contents
# frozen_string_literal: true module Pragma module Operation # Finds all records of the requested resource, authorizes them, paginates them and decorates # them. # # @author Alessandro Desantis class Index < Pragma::Operation::Base step Macro::Classes() step :retrieve!, name: 'retrieve' step :scope!, name: 'scope' step Macro::Filtering() step Macro::Ordering() step Macro::Pagination() step Macro::Decorator(name: :collection) step :respond!, name: 'respond' def retrieve!(options) options['model'] = options['model.class'].all end def scope!(options, current_user:, model:, **) options['model'] = options['policy.default.scope.class'].new(current_user, model).resolve end def respond!(options, **) options['result.response'] = Response::Ok.new( entity: options['result.decorator.collection'] ) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pragma-2.3.0 | lib/pragma/operation/index.rb |
pragma-2.2.0 | lib/pragma/operation/index.rb |