Sha256: 968541c393ed1bbdd66270a6cba8ec6f08095c2b4f904d435bfbc95c55876d1f

Contents?: true

Size: 632 Bytes

Versions: 2

Compression:

Stored size: 632 Bytes

Contents

module Federails
  module Client
    class FollowingPolicy < Federails::FederailsPolicy
      def show?
        in_following?
      end

      def destroy?
        in_following?
      end

      def accept?
        in_following? && @record.target_actor_id == @user.actor.id
      end

      def follow?
        create?
      end

      class Scope < Scope
        def resolve
          scope.with_actor(@user.actor)
        end
      end

      private

      def in_following?
        return false if @user.blank?

        @record.actor_id == @user.actor.id || @record.target_actor_id == @user.actor.id
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
federails-0.2.0 app/policies/federails/client/following_policy.rb
federails-0.1.0 app/policies/federails/client/following_policy.rb