Class: AgentPolicy
- Inherits:
-
ApplicationPolicy
- Object
- ApplicationPolicy
- AgentPolicy
- Defined in:
- app/policies/agent_policy.rb
Instance Method Summary collapse
Instance Method Details
#create? ⇒ Boolean
19 20 21 |
# File 'app/policies/agent_policy.rb', line 19 def create? true if user.try(:has_role?, 'Librarian') end |
#destroy? ⇒ Boolean
27 28 29 |
# File 'app/policies/agent_policy.rb', line 27 def destroy? true if user.try(:has_role?, 'Librarian') end |
#index? ⇒ Boolean
2 3 4 |
# File 'app/policies/agent_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/agent_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
23 24 25 |
# File 'app/policies/agent_policy.rb', line 23 def update? true if user.try(:has_role?, 'Librarian') end |