class RoomPolicy
  attr_reader :user, :model

  def initialize(user, model)
    @user = user || User.new
    @room = model
  end

  class Scope
    def initialize(user, scope)
      @user  = user
      @scope = scope
    end

    def resolve
      if user.admin?
        scope.all
      else
        #TODO: private chats
        scope.all
      end
    end

    private

    attr_reader :user, :scope
  end

  def index?
    true
  end

  def show?
    true
  end

  def new?
    @user.admin? || @user.signed_in?
  end

  def create?
    @user.admin? || @user.signed_in?
  end

  def edit?
    @user.admin? || @user == @room.user
  end

  def update?
    @user.admin? || @user == @room.user
  end

  def destroy?
    @user.admin? || @user == @room.user
  end
end
