Method: Oso::Oso#initialize

Defined in:
lib/oso/oso.rb

#initialize(not_found_error: NotFoundError, forbidden_error: ForbiddenError, read_action: 'read') ⇒ Oso

Create an Oso instance, which is used to configure and enforce an Oso policy in an app.

Parameters:

  • forbidden_error (Class) (defaults to: ForbiddenError)

    Optionally override the “forbidden” error class thrown by the authorize* methods. Defaults to ForbiddenError.

  • not_found_error (Class) (defaults to: NotFoundError)

    Optionally override the “not found” error class thrown by #authorize. Defaults to NotFoundError.

  • read_action (defaults to: 'read')

    The action used by the #authorize method to determine whether an authorization failure should raise a NotFoundError or a ForbiddenError



20
21
22
23
24
25
# File 'lib/oso/oso.rb', line 20

def initialize(not_found_error: NotFoundError, forbidden_error: ForbiddenError, read_action: 'read')
  super()
  @not_found_error = not_found_error
  @forbidden_error = forbidden_error
  @read_action = read_action
end