Class: BloodContracts::Instrumentation::Config
- Inherits:
-
Object
- Object
- BloodContracts::Instrumentation::Config
- Defined in:
- lib/blood_contracts/instrumentation/config.rb
Overview
Class that configures the instrumentation for refinement types matching
Instance Attribute Summary collapse
-
#finalizer_pool_size ⇒ Integer
Pool size of finalizer instance.
-
#instruments ⇒ Hash<Regexp, Array<Instrument>>
readonly
Map of instrument classes where the key is the matching pattern.
-
#session_finalizer ⇒ Symbol
Type of finalizer instance.
-
#types ⇒ Array<BC::Refined>
readonly
List of refinement types defined in the app.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
Initialize the config with default values Also inits the SessionFinalizer.
-
#instrument(pattern, processor, **kwargs) ⇒ Nothing
Main setting in the config Define an instument for Refinement Types, applies only to types matched by the pattern by type class name.
Constructor Details
#initialize ⇒ Config
Initialize the config with default values Also inits the SessionFinalizer
35 36 37 38 39 40 41 42 |
# File 'lib/blood_contracts/instrumentation/config.rb', line 35 def initialize @instruments = {} @finalizer_pool_size = SessionFinalizer::DEFAULT_POOL_SIZE @session_finalizer = :basic reset_types! reset_session_finalizer! end |
Instance Attribute Details
#finalizer_pool_size ⇒ Integer
Pool size of finalizer instance
25 26 27 |
# File 'lib/blood_contracts/instrumentation/config.rb', line 25 def finalizer_pool_size @finalizer_pool_size end |
#instruments ⇒ Hash<Regexp, Array<Instrument>> (readonly)
Map of instrument classes where the key is the matching pattern
13 14 15 |
# File 'lib/blood_contracts/instrumentation/config.rb', line 13 def instruments @instruments end |
#session_finalizer ⇒ Symbol
Type of finalizer instance
31 32 33 |
# File 'lib/blood_contracts/instrumentation/config.rb', line 31 def session_finalizer @session_finalizer end |
#types ⇒ Array<BC::Refined> (readonly)
List of refinement types defined in the app
19 20 21 |
# File 'lib/blood_contracts/instrumentation/config.rb', line 19 def types @types end |
Instance Method Details
#instrument(pattern, processor, **kwargs) ⇒ Nothing
Main setting in the config Define an instument for Refinement Types, applies only to types matched by the pattern by type class name
87 88 89 90 91 92 93 94 95 |
# File 'lib/blood_contracts/instrumentation/config.rb', line 87 def instrument(pattern, processor, **kwargs) pattern = /#{pattern}/i unless pattern.is_a?(Regexp) old_value = @instruments[pattern].to_a new_value = old_value << Instrument.build(processor, **kwargs) @instruments[pattern] = new_value reset_cache!(pattern) end |