Module: Dry::Effects::Providers::CurrentTime::TimeGenerators

Included in:
Dry::Effects::Providers::CurrentTime, Timestamp
Defined in:
lib/dry/effects/providers/current_time/time_generators.rb

Constant Summary collapse

FixedTimeGenerator =
lambda do
  time = ::Time.now
  lambda do |refresh: false, **|
    time = ::Time.now if refresh
    time
  end
end
RunningTime =
-> ** { ::Time.now }
RunningTimeGenerator =
-> { RunningTime }
IncrementingTimeGenerator =
lambda do |initial, step|
  start = Undefined.default(initial) { ::Time.now }
  current = nil

  lambda do |**|
    if current.nil?
      current = start
    else
      current += step
    end
  end
end