Class: Pageflow::MembershipPolicy

Inherits:
ApplicationPolicy show all
Defined in:
app/policies/pageflow/membership_policy.rb

Defined Under Namespace

Classes: Scope

Instance Method Summary collapse

Constructor Details

#initialize(user, membership) ⇒ MembershipPolicy

Returns a new instance of MembershipPolicy.



45
46
47
48
# File 'app/policies/pageflow/membership_policy.rb', line 45

def initialize(user, membership)
  @user = user
  @membership = membership
end

Instance Method Details

#create?Boolean

Returns:

  • (Boolean)


50
51
52
53
54
55
56
# File 'app/policies/pageflow/membership_policy.rb', line 50

def create?
  if @membership.entity_type == 'Pageflow::Account'
    create_for_account?
  else
    create_for_entry?
  end
end

#destroy?Boolean

Returns:

  • (Boolean)


66
67
68
69
70
71
72
# File 'app/policies/pageflow/membership_policy.rb', line 66

def destroy?
  if @membership.entity_type == 'Pageflow::Account'
    destroy_for_account?
  else
    destroy_for_entry?
  end
end

#edit_role?Boolean

Returns:

  • (Boolean)


58
59
60
61
62
63
64
# File 'app/policies/pageflow/membership_policy.rb', line 58

def edit_role?
  if @membership.entity_type == 'Pageflow::Account'
    edit_role_on_account?
  else
    edit_role_on_entry?
  end
end