Module: Bparity::Recording::Determinism
- Defined in:
- lib/bparity/recording.rb
Constant Summary collapse
- TIME_KEY =
:bparity_frozen_time- RANDOM_KEY =
:bparity_previous_random_seed
Class Method Summary collapse
Class Method Details
.apply(config) ⇒ Object
179 180 181 182 183 184 185 186 187 188 |
# File 'lib/bparity/recording.rb', line 179 def apply(config) Thread.current[RANDOM_KEY] = srand(config[:random_seed]) if config[:random_seed] return unless config[:freeze_time] install_time_hook install_date_hook Thread.current[TIME_KEY] = Time.parse(config[:freeze_time].to_s) rescue ArgumentError raise ConfigurationError, "Frozen time is invalid. Use an ISO 8601 value in the boundary configuration." end |
.clear ⇒ Object
190 191 192 193 194 195 |
# File 'lib/bparity/recording.rb', line 190 def clear Thread.current[TIME_KEY] = nil previous_seed = Thread.current[RANDOM_KEY] srand(previous_seed) if previous_seed Thread.current[RANDOM_KEY] = nil end |