Class: GraphQL::Pundit::Instrumenters::Authorization
- Inherits:
-
Object
- Object
- GraphQL::Pundit::Instrumenters::Authorization
- Defined in:
- lib/graphql-pundit/instrumenters/authorization.rb
Overview
Instrumenter that supplies ‘authorize`
Defined Under Namespace
Classes: AuthorizationResolver
Instance Attribute Summary collapse
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
Instance Method Summary collapse
-
#initialize(current_user = :current_user) ⇒ Authorization
constructor
A new instance of Authorization.
- #instrument(_type, field) ⇒ Object
Constructor Details
#initialize(current_user = :current_user) ⇒ Authorization
Returns a new instance of Authorization.
59 60 61 |
# File 'lib/graphql-pundit/instrumenters/authorization.rb', line 59 def initialize(current_user = :current_user) @current_user = current_user end |
Instance Attribute Details
#current_user ⇒ Object (readonly)
Returns the value of attribute current_user.
57 58 59 |
# File 'lib/graphql-pundit/instrumenters/authorization.rb', line 57 def current_user @current_user end |
Instance Method Details
#instrument(_type, field) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/graphql-pundit/instrumenters/authorization.rb', line 63 def instrument(_type, field) return field unless field.[:authorize] old_resolver = field.resolve_proc resolver = AuthorizationResolver.new(current_user, old_resolver, field.[:authorize]) field.redefine do resolve resolver end end |