Class: Timecop
- Inherits:
-
Object
- Object
- Timecop
- Defined in:
- lib/timecop/redis/timecop_integration.rb,
lib/timecop/redis.rb,
lib/timecop/redis/version.rb,
lib/timecop/redis/traveler.rb
Overview
We directly patch Timecop class instead of mixin module since Singleton classes cannot be extended. github.com/ruby/ruby/blob/v2_5_0/lib/singleton.rb#L150-L151
Defined Under Namespace
Modules: Redis
Instance Method Summary collapse
- #travel_with_redis(*args, &block) ⇒ Object (also: #travel)
Instance Method Details
#travel_with_redis(*args, &block) ⇒ Object Also known as: travel
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/timecop/redis/timecop_integration.rb', line 9 def travel_with_redis(*args, &block) if Timecop::Redis.integrate_into_timecop_travel? old_time = Time.now travel_without_redis(*args, &block) new_time = Time.now Timecop::Redis.traveler.travel(from: old_time, to: new_time, &block) else travel_without_redis(*args, &block) end end |