Class: BloodContracts::Instrumentation::Instrument
- Inherits:
-
Object
- Object
- BloodContracts::Instrumentation::Instrument
- Defined in:
- lib/blood_contracts/instrumentation/instrument.rb
Overview
Base class for instrumentation tooling
Class Method Summary collapse
-
.build(proto, before: nil, after: nil) ⇒ Instrument, #call
Builds an Instrument class from the proto and before/after callbacks.
Instance Method Summary collapse
-
#after(_session) ⇒ Nothing
Predefined interface for Instrument after callback, do-no.
-
#before(_session) ⇒ Nothing
Predefined interface for Instrument before callback, do-no.
-
#call(_session) ⇒ Nothing
Predefined interface for Instrument finalization call, do-no.
Class Method Details
.build(proto, before: nil, after: nil) ⇒ Instrument, #call
Builds an Instrument class from the proto and before/after callbacks
When ‘proto` is just a Proc - we create new Instrument class around Otherwise - use the `proto` object as an instrument
Also if before/after is defined we add the definition to the ‘proto`
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/blood_contracts/instrumentation/instrument.rb', line 26 def build(proto, before: nil, after: nil) raise ArgumentError unless proto.respond_to?(:call) instance = instrument_from_proc(proto) if before.respond_to?(:call) instance.define_singleton_method(:before, &before) end define_stub(instance, :before) if after.respond_to?(:call) instance.define_singleton_method(:after, &after) end define_stub(instance, :after) instance end |
Instance Method Details
#after(_session) ⇒ Nothing
Predefined interface for Instrument after callback, do-no
77 |
# File 'lib/blood_contracts/instrumentation/instrument.rb', line 77 def after(_session); end |
#before(_session) ⇒ Nothing
Predefined interface for Instrument before callback, do-no
69 |
# File 'lib/blood_contracts/instrumentation/instrument.rb', line 69 def before(_session); end |
#call(_session) ⇒ Nothing
Predefined interface for Instrument finalization call, do-no
85 |
# File 'lib/blood_contracts/instrumentation/instrument.rb', line 85 def call(_session); end |