aegis v0.1.1 Aegis.PolicyFinder View Source

Finds policy module for corresponding data structure. Policies are found via the following naming convention:

The policy for a given resource should be named by appending “Policy” to the module name of the resource.

E.g.) for resource X, the corresponding policy would be defined as X.Policy

Link to this section Summary

Functions

Finds the policy module based off of the data structure of the provided argument. If a corresponding policy is not found, :error is returned

Link to this section Functions

Link to this function call(arg) View Source
call(any()) :: module() | :error

Finds the policy module based off of the data structure of the provided argument. If a corresponding policy is not found, :error is returned.

Examples:

  • when Puppy.Policy is defined

    iex> Aegis.PolicyFinder.call(Puppy)

    iex> Aegis.PolicyFinder.call(%Puppy{})

  • when a policy is not defined for a structure

    iex> Aegis.PolicyFinder.call(Kitten)

    iex> Aegis.PolicyFinder.call(%Kitten{})

    iex> Aegis.PolicyFinder.call(nil)