terminator v0.1.4 Terminator.Role View Source

Role is grouped representation of multiple abilities. It allows you to assign or manage multiple roles at once.

Link to this section Summary

Types

t()

A role struct

Link to this section Types

Link to this type

t() View Source
t() :: %Terminator.Role{
  __meta__: term(),
  abilities: term(),
  id: term(),
  identifier: term(),
  inserted_at: term(),
  name: term(),
  updated_at: term()
}

A role struct

Link to this section Functions

Link to this function

build(identifier, abilities, name) View Source
build(identifier :: String.t(), abilities :: [String.t()], name :: String.t()) ::
  Ecto.Changeset.t()

Builds ecto changeset for a role.

Examples

iex> changeset = Terminator.Role.build("admin", ["delete_account"], "Administrator of application")
#Ecto.Changeset<
  action: nil,
  changes: %{
  abilities: ["delete_account"],
  identifier: "admin",
  name: "Administrator of application"
},
errors: [],
data: #Terminator.Role<>,
valid?: true
>
iex> changeset |> Repo.insert
{:ok,
%Terminator.Role{
  __meta__: #Ecto.Schema.Metadata<:loaded, "terminator_roles">,
  abilities: ["delete_account"],
  id: 1,
  identifier: "admin",
  inserted_at: ~N[2019-01-03 19:50:13],
  name: "Administrator of application",
  updated_at: ~N[2019-01-03 19:50:13]
}}
Link to this function

changeset(struct, params \\ %{}) View Source
changeset(struct :: Terminator.Role.t(), params :: map() | nil) ::
  Ecto.Changeset.t()