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.
61 62 63 |
# File 'lib/graphql-pundit/instrumenters/authorization.rb', line 61 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.
59 60 61 |
# File 'lib/graphql-pundit/instrumenters/authorization.rb', line 59 def current_user @current_user end |
Instance Method Details
#instrument(_type, field) ⇒ Object
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/graphql-pundit/instrumenters/authorization.rb', line 65 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 |