Class: ManifestationPolicy
- Inherits:
-
ApplicationPolicy
- Object
- ApplicationPolicy
- ManifestationPolicy
- Defined in:
- app/policies/manifestation_policy.rb
Instance Method Summary collapse
- #create? ⇒ Boolean
- #destroy? ⇒ Boolean
- #edit? ⇒ Boolean
- #index? ⇒ Boolean
- #show? ⇒ Boolean
- #update? ⇒ Boolean
Instance Method Details
#create? ⇒ Boolean
19 20 21 |
# File 'app/policies/manifestation_policy.rb', line 19 def create? true if user.try(:has_role?, 'Librarian') end |
#destroy? ⇒ Boolean
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/policies/manifestation_policy.rb', line 38 def destroy? if record.items.empty? if !record.try(:is_reserved?) if record.series_master? if record.children.empty? case user.try(:role).try(:name) when 'Administrator' true when 'Librarian' true if record.required_role_id <= 3 else false end else false end else case user.try(:role).try(:name) when 'Administrator' true when 'Librarian' true if record.required_role_id <= 3 else false end end end end end |
#edit? ⇒ Boolean
23 24 25 26 27 28 29 30 31 32 |
# File 'app/policies/manifestation_policy.rb', line 23 def edit? case user.try(:role).try(:name) when 'Administrator' true when 'Librarian' true if record.required_role_id <= 3 when 'User' true if record.required_role_id <= 2 end end |
#index? ⇒ Boolean
2 3 4 |
# File 'app/policies/manifestation_policy.rb', line 2 def index? true end |
#show? ⇒ Boolean
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/policies/manifestation_policy.rb', line 6 def show? case user.try(:role).try(:name) when 'Administrator' true when 'Librarian' true if record.required_role_id <= 3 when 'User' true if record.required_role_id <= 2 else true if record.required_role_id <= 1 end end |
#update? ⇒ Boolean
34 35 36 |
# File 'app/policies/manifestation_policy.rb', line 34 def update? true if user.try(:has_role?, 'Librarian') end |