Sha256: a4dc1bc51110e9d8c18e9385751c15fc6013b7ec8239e29bb6fbac452bc7ab12

Contents?: true

Size: 683 Bytes

Versions: 4

Compression:

Stored size: 683 Bytes

Contents

# frozen_string_literal: true

require 'dry/effects/effect'

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

        def initialize(options = EMPTY_HASH)
          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.1.5 lib/dry/effects/effects/timestamp.rb
dry-effects-0.1.4 lib/dry/effects/effects/timestamp.rb
dry-effects-0.1.3 lib/dry/effects/effects/timestamp.rb
dry-effects-0.1.2 lib/dry/effects/effects/timestamp.rb