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
rubocop:enable Metrics/ParameterLists.
-
#initialize(*args, policy: nil, record: nil, before_scope: nil, after_scope: nil, **kwargs, &block) ⇒ Object
rubocop:disable Metrics/ParameterLists.
- #resolve(obj, args, ctx) ⇒ Object (also: #resolve_field)
Class Method Details
Instance Method Details
#after_scope(scope = true) ⇒ Object
32 33 34 |
# File 'lib/graphql-pundit/scope.rb', line 32 def after_scope(scope = true) @after_scope = scope end |
#before_scope(scope = true) ⇒ Object
rubocop:enable Metrics/ParameterLists
28 29 30 |
# File 'lib/graphql-pundit/scope.rb', line 28 def before_scope(scope = true) @before_scope = scope end |
#initialize(*args, policy: nil, record: nil, before_scope: nil, after_scope: nil, **kwargs, &block) ⇒ Object
rubocop:disable Metrics/ParameterLists
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/graphql-pundit/scope.rb', line 14 def initialize(*args, policy: nil, record: nil, before_scope: nil, after_scope: nil, **kwargs, &block) @before_scope = before_scope @after_scope = after_scope @policy = policy @record = record super(*args, **kwargs, &block) end |
#resolve(obj, args, ctx) ⇒ Object Also known as: resolve_field
36 37 38 39 40 |
# File 'lib/graphql-pundit/scope.rb', line 36 def resolve(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 |