Class: GraphQL::Pundit::Instrumenters::Scope
- Inherits:
-
Object
- Object
- GraphQL::Pundit::Instrumenters::Scope
- Defined in:
- lib/graphql-pundit/instrumenters/scope.rb
Overview
Base instrumenter for ‘before_scope` and `after_scope`
Direct Known Subclasses
Defined Under Namespace
Classes: ScopeResolver
Instance Attribute Summary collapse
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
Instance Method Summary collapse
-
#initialize(current_user = :current_user) ⇒ Scope
constructor
A new instance of Scope.
-
#instrument(_type, field) ⇒ Object
rubocop:disable Metrics/MethodLength.
Constructor Details
#initialize(current_user = :current_user) ⇒ Scope
Returns a new instance of Scope.
67 68 69 |
# File 'lib/graphql-pundit/instrumenters/scope.rb', line 67 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.
65 66 67 |
# File 'lib/graphql-pundit/instrumenters/scope.rb', line 65 def current_user @current_user end |
Instance Method Details
#instrument(_type, field) ⇒ Object
rubocop:disable Metrics/MethodLength
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/graphql-pundit/instrumenters/scope.rb', line 72 def instrument(_type, field) # rubocop:enable Metrics/MethodLength = field.[self.class::SCOPE_KEY] return field unless scope = [:proc] old_resolver = field.resolve_proc resolver = self.class::ScopeResolver.new(current_user, scope, old_resolver, field) field.redefine do resolve resolver end end |