Zephyr (zephyr v1.0.0-alpha.1)

Documentation for Zephyr.

Summary

Functions

Checks if the given subject has access to the given object based on the given relation

List subjects who has relation to the object

Inserts a new relation between the given subject and object

Similar to write/2 but raises an error if the relation could not be inserted

Types

@type object() :: {namespace :: String.t(), key :: any(), predicate :: String.t()}
@type subject() :: {namespace :: String.t(), key :: any(), predicate :: String.t()}

Functions

Link to this function

check(object, relation, subject, repo_opts \\ [])

@spec check(
  object :: Ecto.Schema.t(),
  relation :: String.t(),
  subject :: Ecto.Schema.t(),
  repo_opts :: Keyword.t()
) :: boolean()

Checks if the given subject has access to the given object based on the given relation

Link to this function

read(object, relation, repo_opts \\ [])

@spec read(
  object :: Ecto.Schema.t(),
  relation :: String.t(),
  repo_opts :: Keyword.t()
) :: [subject()]

List subjects who has relation to the object

Link to this function

write(subject, object, repo_opts \\ [])

@spec write(
  subject :: subject(),
  object :: object(),
  repo_opts :: Keyword.t()
) :: {:ok, Ecto.Changeset.Relation.t()} | {:error, Ecto.Changeset.t()}

Inserts a new relation between the given subject and object

Link to this function

write!(subject, object, repo_opts \\ [])

@spec write!(
  subject :: subject(),
  object :: object(),
  repo_opts :: Keyword.t()
) :: Ecto.Changeset.Relation.t()

Similar to write/2 but raises an error if the relation could not be inserted