Class: AdminPolicy
- Inherits:
-
Struct
- Object
- Struct
- AdminPolicy
- Defined in:
- app/policies/admin_policy.rb
Instance Attribute Summary collapse
-
#admin ⇒ Object
Returns the value of attribute admin.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
- #create? ⇒ Boolean
- #destroy? ⇒ Boolean
-
#initialize(user, admin) ⇒ AdminPolicy
constructor
A new instance of AdminPolicy.
- #manage? ⇒ Boolean
- #read? ⇒ Boolean
- #update? ⇒ Boolean
Constructor Details
#initialize(user, admin) ⇒ AdminPolicy
Returns a new instance of AdminPolicy.
4 5 6 7 |
# File 'app/policies/admin_policy.rb', line 4 def initialize(user, admin) @user = user @admin = admin end |
Instance Attribute Details
#admin ⇒ Object
Returns the value of attribute admin
1 2 3 |
# File 'app/policies/admin_policy.rb', line 1 def admin @admin end |
#user ⇒ Object
Returns the value of attribute user
1 2 3 |
# File 'app/policies/admin_policy.rb', line 1 def user @user end |
Instance Method Details
#create? ⇒ Boolean
9 10 11 |
# File 'app/policies/admin_policy.rb', line 9 def create? manage? end |
#destroy? ⇒ Boolean
21 22 23 |
# File 'app/policies/admin_policy.rb', line 21 def destroy? manage? end |
#manage? ⇒ Boolean
25 26 27 28 29 |
# File 'app/policies/admin_policy.rb', line 25 def manage? action = Storytime::Action.find_by(guid: "3fj09k") role = @user.storytime_role_in_site(Storytime::Site.current) role.present? && role.allowed_actions.include?(action) end |
#read? ⇒ Boolean
13 14 15 |
# File 'app/policies/admin_policy.rb', line 13 def read? manage? end |
#update? ⇒ Boolean
17 18 19 |
# File 'app/policies/admin_policy.rb', line 17 def update? manage? end |