View Source Rolex.Queryable (Rolex v0.1.1)
Use this module to add role-based query scoping functions to a context.
Summary
Functions
Scopes query
to records that are the object ("what") of a granted permission.
Scopes query
to records that are the subject ("who") of a granted permission.
Functions
Scopes query
to records that are the object ("what") of a granted permission.
Permission scope itself is controlled by opts
.
Options
* :role - names the granted role
* :to - the permission subject ("who")
Examples
# tasks where :some_role is granted to a particular user
iex> from(t in Task) |> where_granted_on(role: :some_role, to: user)
Scopes query
to records that are the subject ("who") of a granted permission.
Permission scope itself is controlled by opts
.
Options
* :role - names the granted role
* :on - the permission object ("what")
Examples
# users where :some_role is granted on a particular task
iex> from(u in User) |> where_granted_to(role: :some_role, on: task)