View Source Permit.Actions.Traversal (permit v0.1.3)

Intended for usage by Permit.Resolver and derivatives. Traverses the tree of action definitions defined with Permit.Actions to construct a result based on a given context. The context includes:

  • the action name to be authorized
  • a function that returns a value indicating whether an authorization condition is satisfied
  • a function for the conjunction of values ("AND")
  • a function for the disjunction values ("OR")

Depending on the intended resolution product, these functions are different.

In Permit's vanilla resolver, each record must be checked against authorization conditions for its inclusion in the results. Thus, the passed value function returns a boolean (based on whether there is permission to given action), and the conjunctor and disjunctor are Enum.all?/1 and Enum.any?/1, respectively.

In Permit.Ecto resolver, which constructs query structures based on authorization conditions, the values are Ecto dynamic query expressions converted from the authorization conditions, whereas the conjunctor joins values using SQL AND, and the disjunctor uses SQL OR.

Part of the private API, subject to changes and not to be used on the application level.