Class: Pageflow::EntryPolicy
- Inherits:
-
ApplicationPolicy
- Object
- ApplicationPolicy
- Pageflow::EntryPolicy
- Defined in:
- app/policies/pageflow/entry_policy.rb
Defined Under Namespace
Classes: Scope
Instance Attribute Summary collapse
-
#query ⇒ Object
readonly
Returns the value of attribute query.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #add_member_to? ⇒ Boolean
- #confirm_encoding? ⇒ Boolean
- #create? ⇒ Boolean
- #create_any? ⇒ Boolean
- #destroy? ⇒ Boolean
- #destroy_membership_on? ⇒ Boolean
- #duplicate? ⇒ Boolean
- #edit? ⇒ Boolean
- #edit_outline? ⇒ Boolean
- #edit_role_on? ⇒ Boolean
- #filter_by_type? ⇒ Boolean
- #index_widgets_for? ⇒ Boolean
-
#initialize(user, entry) ⇒ EntryPolicy
constructor
A new instance of EntryPolicy.
- #manage? ⇒ Boolean
- #manage_account_of? ⇒ Boolean
- #preview? ⇒ Boolean
- #publish? ⇒ Boolean
- #publish_on_account_of? ⇒ Boolean
- #read? ⇒ Boolean
- #record ⇒ Object
- #restore? ⇒ Boolean
- #snapshot? ⇒ Boolean
- #update_account_on? ⇒ Boolean
- #update_feature_configuration_on? ⇒ Boolean
- #update_site_on? ⇒ Boolean
- #use_files? ⇒ Boolean
Constructor Details
#initialize(user, entry) ⇒ EntryPolicy
Returns a new instance of EntryPolicy.
39 40 41 42 43 |
# File 'app/policies/pageflow/entry_policy.rb', line 39 def initialize(user, entry) @user = user @entry = entry @query = EntryRoleQuery.new(user, entry) end |
Instance Attribute Details
#query ⇒ Object (readonly)
Returns the value of attribute query.
37 38 39 |
# File 'app/policies/pageflow/entry_policy.rb', line 37 def query @query end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
37 38 39 |
# File 'app/policies/pageflow/entry_policy.rb', line 37 def user @user end |
Instance Method Details
#add_member_to? ⇒ Boolean
110 111 112 |
# File 'app/policies/pageflow/entry_policy.rb', line 110 def add_member_to? manage? end |
#confirm_encoding? ⇒ Boolean
69 70 71 |
# File 'app/policies/pageflow/entry_policy.rb', line 69 def confirm_encoding? edit? end |
#create? ⇒ Boolean
97 98 99 |
# File 'app/policies/pageflow/entry_policy.rb', line 97 def create? query.has_at_least_account_role?(:publisher) end |
#create_any? ⇒ Boolean
93 94 95 |
# File 'app/policies/pageflow/entry_policy.rb', line 93 def create_any? AccountPolicy::Scope.new(@user, Account).entry_creatable.any? end |
#destroy? ⇒ Boolean
146 147 148 |
# File 'app/policies/pageflow/entry_policy.rb', line 146 def destroy? manage_account_of? end |
#destroy_membership_on? ⇒ Boolean
118 119 120 |
# File 'app/policies/pageflow/entry_policy.rb', line 118 def destroy_membership_on? manage? end |
#duplicate? ⇒ Boolean
101 102 103 |
# File 'app/policies/pageflow/entry_policy.rb', line 101 def duplicate? publish? end |
#edit? ⇒ Boolean
65 66 67 |
# File 'app/policies/pageflow/entry_policy.rb', line 65 def edit? query.has_at_least_role?(:editor) end |
#edit_outline? ⇒ Boolean
73 74 75 |
# File 'app/policies/pageflow/entry_policy.rb', line 73 def edit_outline? edit? end |
#edit_role_on? ⇒ Boolean
114 115 116 |
# File 'app/policies/pageflow/entry_policy.rb', line 114 def edit_role_on? manage? end |
#filter_by_type? ⇒ Boolean
49 50 51 |
# File 'app/policies/pageflow/entry_policy.rb', line 49 def filter_by_type? user.admin? end |
#index_widgets_for? ⇒ Boolean
77 78 79 |
# File 'app/policies/pageflow/entry_policy.rb', line 77 def edit? end |
#manage? ⇒ Boolean
105 106 107 108 |
# File 'app/policies/pageflow/entry_policy.rb', line 105 def manage? user.admin? || query.has_at_least_role?(:manager) end |
#manage_account_of? ⇒ Boolean
136 137 138 |
# File 'app/policies/pageflow/entry_policy.rb', line 136 def manage_account_of? query.has_at_least_account_role?(:manager) end |
#preview? ⇒ Boolean
53 54 55 |
# File 'app/policies/pageflow/entry_policy.rb', line 53 def preview? query.has_at_least_role?(:previewer) end |
#publish? ⇒ Boolean
89 90 91 |
# File 'app/policies/pageflow/entry_policy.rb', line 89 def publish? query.has_at_least_role?(:publisher) end |
#publish_on_account_of? ⇒ Boolean
122 123 124 |
# File 'app/policies/pageflow/entry_policy.rb', line 122 def publish_on_account_of? query.has_at_least_account_role?(:publisher) end |
#read? ⇒ Boolean
57 58 59 |
# File 'app/policies/pageflow/entry_policy.rb', line 57 def read? preview? end |
#record ⇒ Object
45 46 47 |
# File 'app/policies/pageflow/entry_policy.rb', line 45 def record @entry end |
#restore? ⇒ Boolean
81 82 83 |
# File 'app/policies/pageflow/entry_policy.rb', line 81 def restore? edit? end |
#snapshot? ⇒ Boolean
85 86 87 |
# File 'app/policies/pageflow/entry_policy.rb', line 85 def snapshot? edit? end |
#update_account_on? ⇒ Boolean
126 127 128 |
# File 'app/policies/pageflow/entry_policy.rb', line 126 def update_account_on? publish_on_account_of? end |
#update_feature_configuration_on? ⇒ Boolean
140 141 142 143 144 |
# File 'app/policies/pageflow/entry_policy.rb', line 140 def update_feature_configuration_on? user.admin? || (!.only_admins_may_update_features && manage_account_of?) end |
#update_site_on? ⇒ Boolean
130 131 132 133 134 |
# File 'app/policies/pageflow/entry_policy.rb', line 130 def update_site_on? user.admin? || (!.only_admins_may_update_site && publish_on_account_of?) end |
#use_files? ⇒ Boolean
61 62 63 |
# File 'app/policies/pageflow/entry_policy.rb', line 61 def use_files? preview? end |