AshGrant.Domain (AshGrant v0.14.1)

Copy Markdown View Source

Domain-level extension for AshGrant.

Add this extension to an Ash domain to define shared resolver and scope configurations that are automatically inherited by all resources in the domain that use the AshGrant extension.

Resources can override any inherited setting by defining their own.

Example

defmodule MyApp.Blog do
  use Ash.Domain,
    extensions: [AshGrant.Domain]

  ash_grant do
    resolver MyApp.PermissionResolver

    scope :always, true
    scope :own, expr(author_id == ^actor(:id))
  end

  resources do
    resource MyApp.Blog.Post
    resource MyApp.Blog.Comment
  end
end

Inheritance Rules

ConfigResource has itDomain has itResult
resolverYesYesResource wins
resolverNoYesDomain's resolver used
scope (same name)YesYesResource wins (override)
scopeNoYesDomain scope inherited

Summary

Functions

ash_grant(body)

(macro)