View Source Membership.Plan (ex_membership v1.0.3)

Plan is main representation of a single plan

Summary

Types

t()

A plan struct

Types

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

A plan struct

Functions

Link to this function

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

View Source
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.Plan 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 plan

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

To grant particular feature to a given plan

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

load_plan_feature(plan, map)

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

Revoke given grant type from a member.

Examples

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

To revoke particular feature from a given plan

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

To revoke particular plan from a given feature

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