Class: Synthra::Behaviors::Failure
- Defined in:
- lib/synthra/behaviors/failure.rb
Overview
Failure behavior - simulates service failure
Raises a SimulatedFailure error based on configured probability. This is useful for testing how applications handle service unavailability, timeouts, and other failure scenarios.
Instance Method Summary collapse
-
#apply(result, context = nil) ⇒ Object
Apply the failure behavior.
Constructor Details
This class inherits a constructor from Synthra::Behaviors::Base
Instance Method Details
#apply(result, context = nil) ⇒ Object
Apply the failure behavior
Based on probability, either raises SimulatedFailure or returns the result unchanged.
60 61 62 63 64 65 66 |
# File 'lib/synthra/behaviors/failure.rb', line 60 def apply(result, context = nil) if should_apply? probability = extract_probability raise SimulatedFailure.new(probability: probability) end result end |