Sha256: ca46d31333a458ee2db060ed18028014a6ad9e98c3bd1451b51a556611cb7ca7

Contents?: true

Size: 717 Bytes

Versions: 2

Compression:

Stored size: 717 Bytes

Contents

# frozen_string_literal: true

module GraphQL
  module Pundit
    # Common methods used for authorization and scopes
    module Common
      # Class methods to be included in the Field class
      module ClassMethods
        def current_user(current_user = nil)
          return @current_user unless current_user

          @current_user = current_user
        end
      end

      def self.included(base)
        @current_user = :current_user
        base.extend(ClassMethods)
      end

      def callable?(thing)
        thing.respond_to?(:call)
      end

      def model?(thing)
        thing.respond_to?(:model)
      end

      def object?(thing)
        thing.respond_to?(:object)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
graphql-pundit2-1 lib/graphql-pundit/common.rb
graphql-pundit2-0.9.1 lib/graphql-pundit/common.rb