Sha256: 9a026ad7d3103d95a12cb3432fa5cb4759854d30897324a1002371488d104c42
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
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 # TODO: Turn this into a macro. def scope!(options, model:, **) options['model'] = options['policy.default.scope.class'].new( options['policy.context'] || options['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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pragma-2.4.0 | lib/pragma/operation/index.rb |