Class: Dry::Effects::Effects::Timestamp
- Inherits:
-
Module
- Object
- Module
- Dry::Effects::Effects::Timestamp
- Defined in:
- lib/dry/effects/effects/timestamp.rb
Constant Summary collapse
- Timestamp =
Effect.new(type: :timestamp)
Instance Method Summary collapse
-
#initialize(options = EMPTY_HASH) ⇒ Timestamp
constructor
A new instance of Timestamp.
Constructor Details
#initialize(options = EMPTY_HASH) ⇒ Timestamp
Returns a new instance of Timestamp.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/dry/effects/effects/timestamp.rb', line 9 def initialize( = EMPTY_HASH) super() module_eval do define_method(:timestamp) do |round: Undefined| round_to = Undefined.coalesce(round, .fetch(:round, Undefined)) if Undefined.equal?(round_to) ::Dry::Effects.yield(Timestamp) else ::Dry::Effects.yield(Timestamp.keywords(round_to: round_to)) end end end end |