class Pragma::Operation::Index

Finds all records of the requested resource, authorizes them, paginates them and decorates them.

Public Instance Methods

include!(options) click to toggle source
# File lib/pragma/operation/index.rb, line 22
def include!(options)
  options['model'] = AssociationIncluder
    .load_adaptor(options['model'])
    .include_associations(options['params'][:expand] || [])
end
respond!(options, **) click to toggle source
# File lib/pragma/operation/index.rb, line 36
def respond!(options, **)
  options['result.response'] = Response::Ok.new(
    entity: options['result.decorator.collection']
  )
end
retrieve!(options) click to toggle source
# File lib/pragma/operation/index.rb, line 18
def retrieve!(options)
  options['model'] = options['model.class'].all
end
scope!(options, model:, **) click to toggle source

TODO: Turn this into a macro.

# File lib/pragma/operation/index.rb, line 29
def scope!(options, model:, **)
  options['model'] = options['policy.default.scope.class'].new(
    options['policy.context'] || options['current_user'],
    model
  ).resolve
end