class Dry::Effects::Effects::CurrentTime

Constants

CurrentTime

Public Class Methods

new(**options) click to toggle source
Calls superclass method
# File lib/dry/effects/effects/current_time.rb, line 20
def initialize(**options)
  super()

  module_eval do
    define_method(:current_time) do |opts = EMPTY_HASH|
      round = opts.fetch(:round, Undefined)
      refresh = opts.fetch(:refresh, false)
      round_to = Undefined.coalesce(round, options.fetch(:round, Undefined))

      if Undefined.equal?(round_to) && refresh.equal?(false)
        effect = CurrentTime
      else
        effect = CurrentTime.(round_to: round_to, refresh: refresh)
      end

      ::Dry::Effects.yield(effect)
    end
  end
end