Sha256: 04aaa3ac0378914447f5685cca9564e792811b2992062d428234f2fc0fc12844

Contents?: true

Size: 682 Bytes

Versions: 15

Compression:

Stored size: 682 Bytes

Contents

require 'jsonapi/authorization/default_pundit_authorizer'

module JSONAPI
  module Authorization
    class Configuration
      attr_accessor :authorizer
      attr_accessor :pundit_user

      def initialize
        self.authorizer  = ::JSONAPI::Authorization::DefaultPunditAuthorizer
        self.pundit_user = :user
      end

      def user_context(context)
        if pundit_user.is_a?(Symbol)
          context[pundit_user]
        else
          pundit_user.call(context)
        end
      end
    end

    class << self
      attr_accessor :configuration
    end

    @configuration ||= Configuration.new

    def self.configure
      yield(@configuration)
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
jsonapi-authorization-3.0.2 lib/jsonapi/authorization/configuration.rb
jsonapi-authorization-3.0.1 lib/jsonapi/authorization/configuration.rb
jsonapi-authorization-3.0.0 lib/jsonapi/authorization/configuration.rb
jsonapi-authorization-2.0.0 lib/jsonapi/authorization/configuration.rb
jsonapi-authorization-1.0.0 lib/jsonapi/authorization/configuration.rb
jsonapi-authorization-1.0.0.beta2 lib/jsonapi/authorization/configuration.rb
jsonapi-authorization-1.0.0.beta1 lib/jsonapi/authorization/configuration.rb
jsonapi-authorization-1.0.0.alpha6 lib/jsonapi/authorization/configuration.rb
jsonapi-authorization-1.0.0.alpha5 lib/jsonapi/authorization/configuration.rb
jsonapi-authorization-1.0.0.alpha4 lib/jsonapi/authorization/configuration.rb
jsonapi-authorization-1.0.0.alpha3 lib/jsonapi/authorization/configuration.rb
jsonapi-authorization-1.0.0.alpha2 lib/jsonapi/authorization/configuration.rb
jsonapi-authorization-1.0.0.alpha1 lib/jsonapi/authorization/configuration.rb
jsonapi-authorization-0.8.2 lib/jsonapi/authorization/configuration.rb
jsonapi-authorization-0.8.1 lib/jsonapi/authorization/configuration.rb