Class: Interceptors::LoggingInterceptor

Inherits:
Interceptor show all
Defined in:
lib/interceptors/logging_interceptor.rb

Instance Method Summary collapse

Methods inherited from Interceptor

#around

Constructor Details

#initialize(logger: nil) ⇒ LoggingInterceptor

Returns a new instance of LoggingInterceptor.



5
6
7
# File 'lib/interceptors/logging_interceptor.rb', line 5

def initialize(logger: nil)
  @logger = logger
end

Instance Method Details

#after(_ctx, result) ⇒ Object



13
14
15
16
# File 'lib/interceptors/logging_interceptor.rb', line 13

def after(_ctx, result)
  log(:after, ok: result.ok?, error: result.error&.message)
  result
end

#before(ctx) ⇒ Object



9
10
11
# File 'lib/interceptors/logging_interceptor.rb', line 9

def before(ctx)
  log(:before, ctx: ctx)
end