Module: GraphQL::Pundit::Scope
- Included in:
- Field
- Defined in:
- lib/graphql-pundit/scope.rb
Overview
Scope methods to be included in the used Field class
Class Method Summary collapse
Instance Method Summary collapse
- #after_scope(scope = true) ⇒ Object
- #before_scope(scope = true) ⇒ Object
- #initialize(*args, before_scope: nil, after_scope: nil, **kwargs, &block) ⇒ Object
- #resolve_field(obj, args, ctx) ⇒ Object
Class Method Details
Instance Method Details
#after_scope(scope = true) ⇒ Object
25 26 27 |
# File 'lib/graphql-pundit/scope.rb', line 25 def after_scope(scope = true) @after_scope = scope end |
#before_scope(scope = true) ⇒ Object
21 22 23 |
# File 'lib/graphql-pundit/scope.rb', line 21 def before_scope(scope = true) @before_scope = scope end |
#initialize(*args, before_scope: nil, after_scope: nil, **kwargs, &block) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/graphql-pundit/scope.rb', line 13 def initialize(*args, before_scope: nil, after_scope: nil, **kwargs, &block) @before_scope = before_scope @after_scope = after_scope super(*args, **kwargs, &block) end |
#resolve_field(obj, args, ctx) ⇒ Object
29 30 31 32 33 |
# File 'lib/graphql-pundit/scope.rb', line 29 def resolve_field(obj, args, ctx) before_scope_return = apply_scope(@before_scope, obj, args, ctx) field_return = super(before_scope_return, args, ctx) apply_scope(@after_scope, field_return, args, ctx) end |