Class: PictureFilePolicy
- Inherits:
-
ApplicationPolicy
- Object
- ApplicationPolicy
- PictureFilePolicy
- Defined in:
- app/policies/picture_file_policy.rb
Instance Method Summary collapse
- #create? ⇒ Boolean
- #destroy? ⇒ Boolean
- #edit? ⇒ Boolean
- #index? ⇒ Boolean
- #show? ⇒ Boolean
- #update? ⇒ Boolean
Instance Method Details
#create? ⇒ Boolean
17 18 19 |
# File 'app/policies/picture_file_policy.rb', line 17 def create? true if user.try(:has_role?, 'Librarian') end |
#destroy? ⇒ Boolean
29 30 31 |
# File 'app/policies/picture_file_policy.rb', line 29 def destroy? true if user.try(:has_role?, 'Librarian') end |
#edit? ⇒ Boolean
21 22 23 |
# File 'app/policies/picture_file_policy.rb', line 21 def edit? true if user.try(:has_role?, 'Librarian') end |
#index? ⇒ Boolean
2 3 4 |
# File 'app/policies/picture_file_policy.rb', line 2 def index? true end |
#show? ⇒ Boolean
6 7 8 9 10 11 12 13 14 15 |
# File 'app/policies/picture_file_policy.rb', line 6 def show? case user.try(:role).try(:name) when 'Librarian' true when 'User' true if record.picture_attachable.try(:required_role_id).to_i <= 2 else true if record.picture_attachable.try(:required_role_id).to_i <= 1 end end |
#update? ⇒ Boolean
25 26 27 |
# File 'app/policies/picture_file_policy.rb', line 25 def update? true if user.try(:has_role?, 'Librarian') end |