Sha256: a0cf781920ca6a73e2f328992b9fed3d2e6aca75ecc1a2b77fa758a60f8a921a

Contents?: true

Size: 672 Bytes

Versions: 4

Compression:

Stored size: 672 Bytes

Contents

# frozen_string_literal: true

module Dry
  module Effects
    module Effects
      class Timestamp < ::Module
        Timestamp = Effect.new(type: :timestamp)

        def initialize(options = EMPTY_HASH)
          super()

          module_eval do
            define_method(:timestamp) do |round: Undefined|
              round_to = Undefined.coalesce(round, options.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
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dry-effects-0.5.0 lib/dry/effects/effects/timestamp.rb
dry-effects-0.4.1 lib/dry/effects/effects/timestamp.rb
dry-effects-0.4.0 lib/dry/effects/effects/timestamp.rb
dry-effects-0.3.1 lib/dry/effects/effects/timestamp.rb