Class: Pragma::Operation::Index

Inherits:
Base
  • Object
show all
Defined in:
lib/pragma/operation/index.rb

Overview

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

Author:

  • Alessandro Desantis

Instance Method Summary collapse

Instance Method Details

#respond!(options) ⇒ Object



27
28
29
30
31
# File 'lib/pragma/operation/index.rb', line 27

def respond!(options, **)
  options['result.response'] = Response::Ok.new(
    entity: options['result.decorator.collection']
  )
end

#retrieve!(options) ⇒ Object



19
20
21
# File 'lib/pragma/operation/index.rb', line 19

def retrieve!(options)
  options['model'] = options['model.class'].all
end

#scope!(options, current_user:, model:) ⇒ Object



23
24
25
# File 'lib/pragma/operation/index.rb', line 23

def scope!(options, current_user:, model:, **)
  options['model'] = options['policy.default.scope.class'].new(current_user, model).resolve
end