Class: Dry::Effects::Providers::CurrentTime
- Inherits:
-
Object
- Object
- Dry::Effects::Providers::CurrentTime
- Includes:
- TimeGenerators
- Defined in:
- lib/dry/effects/providers/current_time.rb,
lib/dry/effects/providers/current_time/time_generators.rb
Defined Under Namespace
Modules: TimeGenerators
Constant Summary collapse
- Locate =
Effect.new(type: :current_time, name: :locate)
Constants included from TimeGenerators
TimeGenerators::FixedTimeGenerator, TimeGenerators::IncrementingTimeGenerator, TimeGenerators::RunningTime, 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.
- #current_time(round_to: Undefined, **options) ⇒ Object
-
#locate ⇒ Provider
private
Locate handler in the stack.
- #represent ⇒ String
Instance Attribute Details
#generator ⇒ Object (readonly)
Returns the value of attribute generator.
20 21 22 |
# File 'lib/dry/effects/providers/current_time.rb', line 20 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
25 26 27 28 29 |
# File 'lib/dry/effects/providers/current_time.rb', line 25 def call(*args) gen, = (args) @generator = build_generator(gen, **) yield end |
#current_time(round_to: Undefined, **options) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/dry/effects/providers/current_time.rb', line 31 def current_time(round_to: Undefined, **) time = generator.(**) round = Undefined.coalesce(round_to, self.round) if Undefined.equal?(round) time else time.round(round) end 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
47 48 49 |
# File 'lib/dry/effects/providers/current_time.rb', line 47 def locate self end |
#represent ⇒ String
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/dry/effects/providers/current_time.rb', line 53 def represent if fixed? if generator.nil? "current_time[fixed=true]" else "current_time[fixed=#{generator.().iso8601(6)}]" end else "current_time[fixed=false]" end end |