lib/jsonapi/authorization/configuration.rb in jsonapi-authorization-0.8.0 vs lib/jsonapi/authorization/configuration.rb in jsonapi-authorization-0.8.1
- old
+ new
@@ -2,12 +2,22 @@
module JSONAPI
module Authorization
class Configuration
attr_accessor :authorizer
+ attr_accessor :pundit_user
def initialize
- self.authorizer = ::JSONAPI::Authorization::DefaultPunditAuthorizer
+ 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