35 lines
602 B
Ruby
35 lines
602 B
Ruby
class GamePolicy
|
|
attr_reader :current_user, :model
|
|
|
|
def initialize(current_user, model)
|
|
@current_user = current_user || User.new
|
|
@game = model
|
|
end
|
|
|
|
def index?
|
|
@current_user.admin?
|
|
end
|
|
|
|
def show?
|
|
true
|
|
# @current_user.admin? || @game.players.find_by_soft_token(soft_token: @current_user.soft_token)
|
|
end
|
|
|
|
def update?
|
|
@current_user.admin? # TODO: Allow game owner to edit || @game.owner == @current_user
|
|
end
|
|
|
|
def destroy?
|
|
return false if @current_user == @user
|
|
@current_user.admin?
|
|
end
|
|
|
|
def start?
|
|
true
|
|
end
|
|
|
|
def play_hand?
|
|
true
|
|
end
|
|
end
|