Class: Pageflow::UserPolicy Private
- Inherits:
-
ApplicationPolicy
- Object
- ApplicationPolicy
- Pageflow::UserPolicy
- Defined in:
- app/policies/pageflow/user_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
- #user ⇒ Object readonly private
Instance Method Summary collapse
- #add_account_to? ⇒ Boolean private
- #admin? ⇒ Boolean private
- #create? ⇒ Boolean private
- #create_any? ⇒ Boolean private
- #delete_own_user? ⇒ Boolean private
- #destroy? ⇒ Boolean private
- #index? ⇒ Boolean private
-
#initialize(user, managed_user) ⇒ UserPolicy
constructor
private
A new instance of UserPolicy.
- #read? ⇒ Boolean private
- #redirect_to_user? ⇒ Boolean private
- #see_admin_status? ⇒ Boolean private
- #set_admin? ⇒ Boolean private
- #suspend? ⇒ Boolean private
Constructor Details
#initialize(user, managed_user) ⇒ UserPolicy
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 UserPolicy.
36 37 38 39 |
# File 'app/policies/pageflow/user_policy.rb', line 36 def initialize(user, managed_user) @user = user @managed_user = managed_user end |
Instance Attribute Details
#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.
34 35 36 |
# File 'app/policies/pageflow/user_policy.rb', line 34 def user @user end |
Instance Method Details
#add_account_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.
54 55 56 |
# File 'app/policies/pageflow/user_policy.rb', line 54 def add_account_to? Pageflow.config.allow_multiaccount_users 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.
78 79 80 |
# File 'app/policies/pageflow/user_policy.rb', line 78 def admin? @user.admin? end |
#create? ⇒ 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.
45 46 47 |
# File 'app/policies/pageflow/user_policy.rb', line 45 def create? index? end |
#create_any? ⇒ 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.
41 42 43 |
# File 'app/policies/pageflow/user_policy.rb', line 41 def create_any? index? end |
#delete_own_user? ⇒ 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.
94 95 96 |
# File 'app/policies/pageflow/user_policy.rb', line 94 def delete_own_user? Pageflow.config..call(@managed_user) == true end |
#destroy? ⇒ 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.
74 75 76 |
# File 'app/policies/pageflow/user_policy.rb', line 74 def destroy? deny_sign_in? 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.
49 50 51 52 |
# File 'app/policies/pageflow/user_policy.rb', line 49 def index? @user.admin? || @user.memberships.on_accounts.where(role: 'manager').any? 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.
58 59 60 61 62 63 64 |
# File 'app/policies/pageflow/user_policy.rb', line 58 def read? manager_accounts = AccountPolicy::Scope .new(@user, Account).member_addable managed_user_accounts = AccountPolicy::Scope .new(@managed_user, Account).resolve manager_accounts.intersect?(managed_user_accounts) end |
#redirect_to_user? ⇒ 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.
66 67 68 |
# File 'app/policies/pageflow/user_policy.rb', line 66 def redirect_to_user? read? end |
#see_admin_status? ⇒ 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.
86 87 88 89 90 91 92 |
# File 'app/policies/pageflow/user_policy.rb', line 86 def see_admin_status? if .only_admins_may_see_admin_boolean admin? else read? end end |
#set_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.
82 83 84 |
# File 'app/policies/pageflow/user_policy.rb', line 82 def set_admin? admin? end |
#suspend? ⇒ 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.
70 71 72 |
# File 'app/policies/pageflow/user_policy.rb', line 70 def suspend? deny_sign_in? end |