module BloodContracts::Instrumentation::SessionRecording
Prependable module for matching session recording
Public Class Methods
new(*)
click to toggle source
Adds @session initialization to constructor
Calls superclass method
# File lib/blood_contracts/instrumentation/session_recording.rb, line 8 def initialize(*) super self.class.instruments @session = self.class.session_klass.new(self.class.name) end
prepended(other)
click to toggle source
Modifications in singleton class of BC::Refined
@param other [BC::Refined] class to enhance
rubocop:disable Metrics/MethodLength
# File lib/blood_contracts/instrumentation/session_recording.rb, line 77 def self.prepended(other) class << other prepend Inheritance # Class to use as a session (writer) # # @return [Session] # attr_writer :session_klass # Class to use as a session # By default is set to Session # # @return [Session] # def session_klass @session_klass ||= Session end # Whether type anonymous or not # # @return [Boolean] # def anonymous? name.nil? end # List of instruments for the type # # @return [Array<Instrument>] # def instruments return @instruments if defined? @instruments reset_instruments! end # Alias for instruments reader # See #instruments alias setup_instruments instruments # Reset the List of instruments for the type # Note, that if list of instruments is empty there is no need to # init the session, so type is not prepended by Match wrapper # # @return [Array<Instrument>] # def reset_instruments! @instruments = Instrumentation.select_instruments(name) ensure prepend(Match) unless @instruments.empty? end end end