Class: GraphQL::Pundit::Instrumenter

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql-pundit/instrumenter.rb

Overview

Intrumenter combining the authorization and scope instrumenters

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(current_user = :current_user) ⇒ Instrumenter

Returns a new instance of Instrumenter.



17
18
19
20
21
22
23
24
# File 'lib/graphql-pundit/instrumenter.rb', line 17

def initialize(current_user = :current_user)
  @current_user = current_user
  @authorization_instrumenter =
    Instrumenters::Authorization.new(current_user)
  @before_scope_instrumenter =
    Instrumenters::BeforeScope.new(current_user)
  @after_scope_instrumenter = Instrumenters::AfterScope.new(current_user)
end

Instance Attribute Details

#after_scope_instrumenterObject (readonly)

Returns the value of attribute after_scope_instrumenter.



12
13
14
# File 'lib/graphql-pundit/instrumenter.rb', line 12

def after_scope_instrumenter
  @after_scope_instrumenter
end

#authorization_instrumenterObject (readonly)

Returns the value of attribute authorization_instrumenter.



12
13
14
# File 'lib/graphql-pundit/instrumenter.rb', line 12

def authorization_instrumenter
  @authorization_instrumenter
end

#before_scope_instrumenterObject (readonly)

Returns the value of attribute before_scope_instrumenter.



12
13
14
# File 'lib/graphql-pundit/instrumenter.rb', line 12

def before_scope_instrumenter
  @before_scope_instrumenter
end

#current_userObject (readonly)

Returns the value of attribute current_user.



12
13
14
# File 'lib/graphql-pundit/instrumenter.rb', line 12

def current_user
  @current_user
end

Instance Method Details

#instrument(type, field) ⇒ Object



26
27
28
29
30
31
# File 'lib/graphql-pundit/instrumenter.rb', line 26

def instrument(type, field)
  before_scoped_field = before_scope_instrumenter.instrument(type, field)
  after_scoped_field = after_scope_instrumenter.
    instrument(type, before_scoped_field)
  authorization_instrumenter.instrument(type, after_scoped_field)
end