View Source Membership.Role (ex_membership v1.0.3)

Role is main representation of feature flags assigned to a role

Summary

Types

t()

A Role struct

Types

@type t() :: %Membership.Role{
  __meta__: term(),
  features: term(),
  id: term(),
  identifier: term(),
  name: term()
}

A Role struct

Functions

Link to this function

changeset(struct, params \\ %{})

View Source
Link to this function

create(identifier, name, features \\ [])

View Source
@spec grant(t(), t() | Membership.Feature.t()) :: Member.t()

Grant given grant type to a feature.

Examples

Function accepts either Membership.Role or Membership.Feature grants. Function is merging existing grants with the new ones, so calling grant with same grants will not duplicate entries in table.

To grant particular feature to a given role

iex> Membership.Role.grant(%Membership.Feature{id: 1}, %Membership.Role{id: 1})

To grant particular feature to a given role

iex> Membership.Role.grant(%Membership.Role{id: 1}, %Membership.Feature{id: 1})
Link to this function

load_role_feature(role, map)

View Source
@spec revoke(t(), t() | Membership.Feature.t()) :: Member.t()

Revoke given grant type from a member.

Examples

Function accepts either Membership.Role or Membership.Feature grants. Function is directly opposite of Membership.Member.grant/2

To revoke particular feature from a given plan

iex> Membership.Role.revoke(%Membership.Feature{id: 1}, %Membership.Role{id: 1})

To revoke particular plan from a given feature

iex> Membership.Role.revoke(%Membership.Role{id: 1}, %Membership.Feature{id: 1})