Class: ApplicationPolicy
- Inherits:
-
Object
- Object
- ApplicationPolicy
- Defined in:
- lib/kowl/templates/app/policies/application_policy.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Scope
Instance Attribute Summary collapse
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
-
#record ⇒ Object
readonly
Returns the value of attribute record.
Instance Method Summary collapse
- #admin? ⇒ Boolean
-
#initialize(current_user, record) ⇒ ApplicationPolicy
constructor
A new instance of ApplicationPolicy.
- #staff? ⇒ Boolean
-
#staff_member? ⇒ Boolean
Used to verify if the persons role is set to either superuser or staff.
Constructor Details
#initialize(current_user, record) ⇒ ApplicationPolicy
Returns a new instance of ApplicationPolicy.
6 7 8 9 10 11 |
# File 'lib/kowl/templates/app/policies/application_policy.rb', line 6 def initialize(current_user, record) raise Pundit::NotAuthorizedError, 'must be logged in' unless current_user @current_user = current_user @record = record end |
Instance Attribute Details
#current_user ⇒ Object (readonly)
Returns the value of attribute current_user.
4 5 6 |
# File 'lib/kowl/templates/app/policies/application_policy.rb', line 4 def current_user @current_user end |
#record ⇒ Object (readonly)
Returns the value of attribute record.
4 5 6 |
# File 'lib/kowl/templates/app/policies/application_policy.rb', line 4 def record @record end |
Instance Method Details
#admin? ⇒ Boolean
13 14 15 |
# File 'lib/kowl/templates/app/policies/application_policy.rb', line 13 def admin? current_user.admin? if current_user.present? end |
#staff? ⇒ Boolean
17 18 19 |
# File 'lib/kowl/templates/app/policies/application_policy.rb', line 17 def staff? current_user.staff? if current_user.present? end |
#staff_member? ⇒ Boolean
Used to verify if the persons role is set to either superuser or staff
22 23 24 |
# File 'lib/kowl/templates/app/policies/application_policy.rb', line 22 def staff_member? admin? || staff? end |