Class: Dry::Effects::Providers::Timestamp
- Inherits:
-
Object
- Object
- Dry::Effects::Providers::Timestamp
- Includes:
- CurrentTime::TimeGenerators
- Defined in:
- lib/dry/effects/providers/timestamp.rb
Constant Summary collapse
- Locate =
Effect.new(type: :timestamp, name: :locate)
Constants included from CurrentTime::TimeGenerators
CurrentTime::TimeGenerators::FixedTimeGenerator, CurrentTime::TimeGenerators::IncrementingTimeGenerator, CurrentTime::TimeGenerators::RunningTime, CurrentTime::TimeGenerators::RunningTimeGenerator
Instance Attribute Summary collapse
-
#generator ⇒ Object
readonly
Returns the value of attribute generator.
Instance Method Summary collapse
-
#call(*args) ⇒ Object
private
Yield the block with the handler installed.
-
#locate ⇒ Provider
private
Locate handler in the stack.
- #timestamp(round_to: Undefined, **options) ⇒ Object
Instance Attribute Details
#generator ⇒ Object (readonly)
Returns the value of attribute generator.
14 15 16 |
# File 'lib/dry/effects/providers/timestamp.rb', line 14 def generator @generator end |
Instance Method Details
#call(*args) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Yield the block with the handler installed
19 20 21 22 23 |
# File 'lib/dry/effects/providers/timestamp.rb', line 19 def call(*args) gen, = (args) @generator = build_generator(gen, **) yield end |
#locate ⇒ Provider
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Locate handler in the stack
41 42 43 |
# File 'lib/dry/effects/providers/timestamp.rb', line 41 def locate self end |
#timestamp(round_to: Undefined, **options) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/dry/effects/providers/timestamp.rb', line 25 def (round_to: Undefined, **) time = generator.(**) round = Undefined.coalesce(round_to, self.round) if Undefined.equal?(round) time else time.round(round) end end |