View Source Membership.Member (ex_membership v1.0.3)
Member is a main actor for determining features
Summary
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
Functions
@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})
@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})
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