View Source Membership.Feature (ex_membership v1.0.3)

Feature is main representation of a single feature flag assigned to a plan

Summary

Types

t()

A Feature struct

Types

@type t() :: %Membership.Feature{
  __meta__: term(),
  id: term(),
  identifier: term(),
  name: term(),
  plans: term(),
  roles: term()
}

A Feature struct

Functions

Link to this function

changeset(struct, params \\ %{})

View Source
Link to this function

create(identifier, name)

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

Grant given grant type to a feature.

Examples

Function accepts either Membership.Feature or Membership.Plan 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 plan

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

To grant particular feature to a given plan

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

load_plan_feature(plan, map)

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

Revoke given grant type from a member.

Examples

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

To revoke particular feature from a given plan

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

To revoke particular plan from a given feature

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