class RelationshipPolicy
  attr_reader :user, :relationship

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

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

    def resolve
      if user.admin?
        scope.all
      else
        scope.all
      end
    end

    private

    attr_reader :user, :scope
  end

  def index?
    true
  end

  def show?
    true
  end

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

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

  def edit?
    @user.admin? || @user.id == @relationship.follower_id
  end

  def update?
    @user.admin? || @user.id == @relationship.follower_id
  end

  def destroy?
    @user.admin? || @user.id == @relationship.follower_id
  end
end
