Class: Pageflow::AccountPolicy Private
- Inherits:
-
ApplicationPolicy
- Object
- ApplicationPolicy
- Pageflow::AccountPolicy
- 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
- #query ⇒ Object readonly private
- #user ⇒ Object readonly private
Instance Method Summary collapse
- #add_member_to? ⇒ Boolean private
- #admin? ⇒ Boolean private
- #configure_folder_on? ⇒ Boolean private
- #destroy_membership_on? ⇒ Boolean private
- #edit_role_on? ⇒ Boolean private
- #index? ⇒ Boolean private
-
#initialize(user, account) ⇒ AccountPolicy
constructor
private
A new instance of AccountPolicy.
- #publish? ⇒ Boolean private
- #read? ⇒ Boolean private
- #see_badge_belonging_to? ⇒ Boolean private
- #see_entry_types? ⇒ Boolean private
- #see_user_quota? ⇒ Boolean private
- #update? ⇒ Boolean private
- #update_feature_configuration_on? ⇒ Boolean private
- #update_site_on_entry_of? ⇒ Boolean private
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, account) @user = user @account = account @query = AccountRoleQuery.new(user, account) end |
Instance Attribute Details
#query ⇒ Object (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 |
#user ⇒ Object (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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
81 82 83 84 85 |
# File 'app/policies/pageflow/account_policy.rb', line 81 def update_feature_configuration_on? user.admin? || (!.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.
67 68 69 |
# File 'app/policies/pageflow/account_policy.rb', line 67 def update_site_on_entry_of? publish? end |