Sha256: 42ecd396fb3ab5588bbfc9bfc42b8d291ba9e44e2a3f76adba5737945f49d9e0
Contents?: true
Size: 1.04 KB
Versions: 4
Compression:
Stored size: 1.04 KB
Contents
# frozen_string_literal: true require 'dry/effects/effect' require 'dry/effects/constructors' module Dry module Effects module Effects class CurrentTime < ::Module CurrentTime = Effect.new(type: :current_time) Constructors.register(:CurrentTime) do |**kwargs| if kwargs.empty? CurrentTime else CurrentTime.(**kwargs) end end def initialize(**options) 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 end end end end
Version data entries
4 entries across 4 versions & 1 rubygems