View Source Membership.Member (ex_membership v1.0.3)

Member is a main actor for determining features

Summary

Types

t()

A member struct

Functions

Grant given grant type to a member.

Revoke given grant type from a member.

Sync features column with the member features and member plans pivot tables. we do this for caching reasons, ie holding the plan[feature] and extra feature identifiers summed into a list and stored in features column of the member, we query this to see if member has ex feature vs repo lookup by plan and checking if plan has said feature

Types

@type t() :: %Membership.Member{
  __meta__: term(),
  extra_features: term(),
  features: term(),
  id: term(),
  identifier: term(),
  inserted_at: term(),
  plans: term(),
  roles: term(),
  updated_at: term()
}

A member struct

Functions

Link to this function

changeset(struct, params \\ %{})

View Source
Link to this function

fetch_removed_features(id)

View Source
Link to this function

generate_identifier(changeset)

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

Grant given grant type to a member.

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 member

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

To grant particular plan to a given member

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

grant(member, feature, permission)

View Source
Link to this function

load_member_feature(member, map)

View Source
Link to this function

load_member_plan(member, map)

View Source
Link to this function

load_member_role(member, map)

View Source
@spec revoke(t(), Membership.Feature.t() | Membership.Plan.t()) :: 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 member

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

To revoke particular plan from a given member

iex> Membership.Member.revoke(%Membership.Member{id: 1}, %Membership.Plan{id: 1})
@spec sync_features(t()) :: t()

Sync features column with the member features and member plans pivot tables. we do this for caching reasons, ie holding the plan[feature] and extra feature identifiers summed into a list and stored in features column of the member, we query this to see if member has ex feature vs repo lookup by plan and checking if plan has said feature