Class: Archangel::ApplicationPolicy
- Inherits:
-
Object
- Object
- Archangel::ApplicationPolicy
- Defined in:
- app/policies/archangel/application_policy.rb
Overview
Application base policy
Direct Known Subclasses
AssetPolicy, CollectionPolicy, DesignPolicy, EntryPolicy, PagePolicy, SitePolicy, UserPolicy, WidgetPolicy
Defined Under Namespace
Classes: Scope
Instance Attribute Summary collapse
-
#record ⇒ Object
readonly
Record to check.
-
#user ⇒ Object
readonly
User to check policy for.
Instance Method Summary collapse
-
#create? ⇒ Boolean
Check if ‘#create` action is authorized for current user.
-
#destroy? ⇒ Boolean
Check if ‘#destroy` action is authorized for current user.
-
#edit? ⇒ Boolean
Check if ‘#edit` action is authorized for current user.
-
#index? ⇒ Boolean
Check if ‘#index` action is authorized for current user.
-
#initialize(user, record) ⇒ ApplicationPolicy
constructor
Policy initializer.
-
#new? ⇒ Boolean
Check if ‘#new` action is authorized for current user.
-
#scope ⇒ Boolean
Nested scope.
-
#show? ⇒ Boolean
Check if ‘#show` action is authorized for current user.
-
#update? ⇒ Boolean
Check if ‘#update` action is authorized for current user.
Constructor Details
#initialize(user, record) ⇒ ApplicationPolicy
Policy initializer
24 25 26 27 |
# File 'app/policies/archangel/application_policy.rb', line 24 def initialize(user, record) @user = user @record = record end |
Instance Attribute Details
#record ⇒ Object (readonly)
Record to check
11 12 13 |
# File 'app/policies/archangel/application_policy.rb', line 11 def record @record end |
#user ⇒ Object (readonly)
User to check policy for
16 17 18 |
# File 'app/policies/archangel/application_policy.rb', line 16 def user @user end |
Instance Method Details
#create? ⇒ Boolean
Check if ‘#create` action is authorized for current user
52 53 54 |
# File 'app/policies/archangel/application_policy.rb', line 52 def create? true end |
#destroy? ⇒ Boolean
Check if ‘#destroy` action is authorized for current user
88 89 90 |
# File 'app/policies/archangel/application_policy.rb', line 88 def destroy? true end |
#edit? ⇒ Boolean
Check if ‘#edit` action is authorized for current user
79 80 81 |
# File 'app/policies/archangel/application_policy.rb', line 79 def edit? update? end |
#index? ⇒ Boolean
Check if ‘#index` action is authorized for current user
34 35 36 |
# File 'app/policies/archangel/application_policy.rb', line 34 def index? true end |
#new? ⇒ Boolean
Check if ‘#new` action is authorized for current user
61 62 63 |
# File 'app/policies/archangel/application_policy.rb', line 61 def new? create? end |
#scope ⇒ Boolean
Nested scope
97 98 99 |
# File 'app/policies/archangel/application_policy.rb', line 97 def scope ::Pundit.policy_scope!(user, record.class) end |
#show? ⇒ Boolean
Check if ‘#show` action is authorized for current user
43 44 45 |
# File 'app/policies/archangel/application_policy.rb', line 43 def show? scope.where(id: record.id).exists? end |
#update? ⇒ Boolean
Check if ‘#update` action is authorized for current user
70 71 72 |
# File 'app/policies/archangel/application_policy.rb', line 70 def update? true end |