Class: QueueItemsPolicy

Inherits:
CollectionPolicy show all
Defined in:
app/policies/queue_items_policy.rb

Instance Attribute Summary

Attributes inherited from CollectionPolicy

#user

Instance Method Summary collapse

Methods inherited from CollectionPolicy

#authorize!, #initialize

Constructor Details

This class inherits a constructor from CollectionPolicy

Instance Method Details

#base_scopeObject


5
6
7
# File 'app/policies/queue_items_policy.rb', line 5

def base_scope
  QueueItem.all
end

#create?(request) ⇒ Boolean


13
14
15
# File 'app/policies/queue_items_policy.rb', line 13

def create?(request)
  user&.admin? || request&.user == user
end

#index?Boolean


9
10
11
# File 'app/policies/queue_items_policy.rb', line 9

def index?
  user.known?
end

#resolveObject


17
18
19
20
21
22
23
24
25
# File 'app/policies/queue_items_policy.rb', line 17

def resolve
  if user.admin?
    scope.all
  elsif user.known?
    scope.owned(user.id)
  else
    scope.none
  end
end