thirteen-tien-len/app/policies/table_policy.rb

34 lines
557 B
Ruby

class TablePolicy
attr_reader :current_user, :model
def initialize(current_user, model)
@current_user = current_user || User.new
@table = model
end
def index?
@current_user.admin? || true
end
def show?
@current_user.admin? || @current_user == @user
end
def update?
@current_user.admin? # TODO: Allow table owner to edit || @table.owner == @current_user
end
def destroy?
return false if @current_user == @user
@current_user.admin?
end
def play_now?
true
end
def new_game?
true
end
end