Class: Pageflow::AccountPolicy Private

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

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Classes: Scope

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, account) ⇒ AccountPolicy

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of AccountPolicy.



53
54
55
56
57
# File 'app/policies/pageflow/account_policy.rb', line 53

def initialize(user, )
  @user = user
  @account = 
  @query = AccountRoleQuery.new(user, )
end

Instance Attribute Details

#queryObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



51
52
53
# File 'app/policies/pageflow/account_policy.rb', line 51

def query
  @query
end

#userObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



51
52
53
# File 'app/policies/pageflow/account_policy.rb', line 51

def user
  @user
end

Instance Method Details

#add_member_to?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


87
88
89
90
91
# File 'app/policies/pageflow/account_policy.rb', line 87

def add_member_to?
  Pageflow.config.allow_multiaccount_users &&
    (user.admin? ||
     query.has_at_least_role?(:manager))
end

#admin?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


111
112
113
# File 'app/policies/pageflow/account_policy.rb', line 111

def admin?
  user.admin?
end

#configure_folder_on?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


63
64
65
# File 'app/policies/pageflow/account_policy.rb', line 63

def configure_folder_on?
  publish?
end

#destroy_membership_on?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


107
108
109
# File 'app/policies/pageflow/account_policy.rb', line 107

def destroy_membership_on?
  add_member_to?
end

#edit_role_on?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


103
104
105
# File 'app/policies/pageflow/account_policy.rb', line 103

def edit_role_on?
  user.admin? || query.has_at_least_role?(:manager)
end

#index?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


121
122
123
124
125
# File 'app/policies/pageflow/account_policy.rb', line 121

def index?
  admin? ||
    (Pageflow.config.allow_multiaccount_users &&
     @user.memberships.on_accounts.as_manager.any?)
end

#publish?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


59
60
61
# File 'app/policies/pageflow/account_policy.rb', line 59

def publish?
  user.admin? || query.has_at_least_role?(:publisher)
end

#read?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


71
72
73
74
75
# File 'app/policies/pageflow/account_policy.rb', line 71

def read?
  user.admin? ||
    (query.has_at_least_role?(:manager) &&
     Pageflow.config.allow_multiaccount_users)
end

#see_badge_belonging_to?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


115
116
117
118
119
# File 'app/policies/pageflow/account_policy.rb', line 115

def see_badge_belonging_to?
  @account.entries.intersect?(user.entries) ||
    query.has_at_least_role?(:previewer) ||
    user.admin?
end

#see_entry_types?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


98
99
100
101
# File 'app/policies/pageflow/account_policy.rb', line 98

def see_entry_types?
  user.admin? ||
    query.has_at_least_role?(:publisher)
end

#see_user_quota?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


93
94
95
96
# File 'app/policies/pageflow/account_policy.rb', line 93

def see_user_quota?
  user.admin? ||
    query.has_at_least_role?(:manager)
end

#update?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


77
78
79
# File 'app/policies/pageflow/account_policy.rb', line 77

def update?
  read?
end

#update_feature_configuration_on?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


81
82
83
84
85
# File 'app/policies/pageflow/account_policy.rb', line 81

def update_feature_configuration_on?
  user.admin? ||
    (!permissions_config.only_admins_may_update_features &&
     read?)
end

#update_site_on_entry_of?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


67
68
69
# File 'app/policies/pageflow/account_policy.rb', line 67

def update_site_on_entry_of?
  publish?
end