Class: EventsPolicy

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

Instance Attribute Summary

Attributes inherited from CollectionPolicy

#user

Instance Method Summary collapse

Methods inherited from CollectionPolicy

#authorize!, #create?, #initialize

Constructor Details

This class inherits a constructor from CollectionPolicy

Instance Method Details

#base_scopeObject


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

def base_scope
  Event.all
end

#index?Boolean


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

def index?
  user.known?
end

#resolveObject


13
14
15
16
17
18
19
20
21
# File 'app/policies/events_policy.rb', line 13

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