module BloodContracts::Instrumentation::SessionRecording::Match
Wrapper for BC::Refined#match call, to add instrumentaion Usage:
class JsonType < BC::Refined # now during #match call you will have access to @session prepend BloodContracts::Instrumentation::Match def match context[:parsed] = JSON.parse(value.to_s) self end end
Public Instance Methods
finalize!(result)
click to toggle source
Finish the matching session and delegate finalize to SessionFinalizer
@param result [BC::Refined] result of type matching pipeline
@return [Nothing]
# File lib/blood_contracts/instrumentation/session_recording.rb, line 50 def finalize!(result) @session.finish(result) self.class.instruments.each { |i| i.after(@session) } SessionFinalizer.instance.finalize!(self.class.instruments, @session) end
match()
click to toggle source
Wraps original call in session start and finish call Note that @session.finish(result) is called even when exception was raised during the call
@return [BC::Refined]
Calls superclass method
# File lib/blood_contracts/instrumentation/session_recording.rb, line 32 def match @session.start self.class.instruments.each { |i| i.before(@session) } result = super rescue StandardError => e result = FailedMatch.new(e, context: @context) raise e ensure finalize!(result) end