Class: Bparity::Verification::ExternalProbe
- Inherits:
-
Object
- Object
- Bparity::Verification::ExternalProbe
- Defined in:
- lib/bparity/verification.rb
Constant Summary collapse
- THREAD_KEY =
:bparity_verification_external_calls
Instance Method Summary collapse
- #capture ⇒ Object
-
#initialize(bindings) ⇒ ExternalProbe
constructor
A new instance of ExternalProbe.
- #install! ⇒ Object
Constructor Details
#initialize(bindings) ⇒ ExternalProbe
Returns a new instance of ExternalProbe.
234 235 236 237 |
# File 'lib/bparity/verification.rb', line 234 def initialize(bindings) @bindings = bindings @bindings_by_target = bindings.to_h { |binding| [Bparity.constantize(binding.target), binding] } end |
Instance Method Details
#capture ⇒ Object
244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/bparity/verification.rb', line 244 def capture previous = Thread.current[THREAD_KEY] context = Thread.current[THREAD_KEY] = { calls: [], bindings: @bindings_by_target } value = yield { value:, calls: context.fetch(:calls) } rescue StandardError => e e.instance_variable_set(:@bparity_external_calls, context.fetch(:calls)) raise ensure Thread.current[THREAD_KEY] = previous end |
#install! ⇒ Object
239 240 241 242 |
# File 'lib/bparity/verification.rb', line 239 def install! @bindings.each { |binding| install(binding) } self end |