Sha256: a47d72447fa019af410d950ccd6e265e6a08bfd3c1efdd59a2bed4d38cf9e68c

Contents?: true

Size: 739 Bytes

Versions: 3

Compression:

Stored size: 739 Bytes

Contents

module Theblog
  class ApplicationPolicy
    attr_reader :user, :record

    def initialize(user, record)
      @user = Theblog::Account.find(user.id)
      @record = record
    end

    def index?
      false
    end

    def show?
      scope.where(:id => record.id).exists?
    end

    def create?
      false
    end

    def new?
      create?
    end

    def update?
      false
    end

    def edit?
      update?
    end

    def destroy?
      false
    end

    def scope
      Pundit.policy_scope!(user, record.class)
    end

    class Scope
      attr_reader :user, :scope

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

      def resolve
        scope
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
theblog-0.0.2.3 app/policies/theblog/application_policy.rb
theblog-0.0.2.2 app/policies/theblog/application_policy.rb
theblog-0.0.2.1 app/policies/theblog/application_policy.rb