Class: Carioca::Services::ProxyDebug
- Inherits:
-
Object
- Object
- Carioca::Services::ProxyDebug
- Defined in:
- lib/carioca/services/debug.rb
Instance Method Summary collapse
-
#initialize(service:, trace:) ⇒ ProxyDebug
constructor
A new instance of ProxyDebug.
- #method_missing(methodname, *args, **keywords) ⇒ Object
- #trace(message:) ⇒ Object
Constructor Details
#initialize(service:, trace:) ⇒ ProxyDebug
Returns a new instance of ProxyDebug.
12 13 14 15 16 17 18 19 20 |
# File 'lib/carioca/services/debug.rb', line 12 def initialize(service:, trace:) registry = Carioca::Registry.get @service = registry.get_service name: service @tracers = %i[output logger] raise "Debugger :trace is not valid : #{trace}, must be in : #{@tracers}" unless @tracers.include? trace @tracer = registry.get_service name: trace @tracer_type = trace end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(methodname, *args, **keywords) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/carioca/services/debug.rb', line 22 def method_missing(methodname, *args, **keywords, &) trace message: "BEGIN CALL for service #{@service.class}" trace message: "Method called: #{methodname}" trace message: "args : #{args.join ' '}" trace message: "keywords : #{keywords}" if block_given? trace message: 'block given' a = @service.send(methodname, *args, **keywords, &) else a = @service.send(methodname, *args, **keywords) end trace message: "=> method returned: #{a}" trace message: 'END CALL' a end |
Instance Method Details
#trace(message:) ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/carioca/services/debug.rb', line 39 def trace(message:) if @tracer_type == :output save = @tracer.mode @tracer.mode = :mono @tracer.debug @tracer.mode = save else @tracer.debug('Carioca->ProxyDebug') { } end end |