Sha256: fffc56b228721e48a137ced38ca63956efd2bbac6150a73abfa6e6647a21f2ce

Contents?: true

Size: 437 Bytes

Versions: 5

Compression:

Stored size: 437 Bytes

Contents

# frozen_string_literal: true

require "dry/monads"

module Rubysmith
  module Configuration
    # Adds current time to content.
    module Transformers
      include Dry::Monads[:result]

      CurrentTime = lambda do |content, at: Time.now|
        content.fetch(:now) { at }
               .then { |now| content.merge! now: }
               .then { |updated_content| Dry::Monads::Success updated_content }
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rubysmith-5.4.0 lib/rubysmith/configuration/transformers/current_time.rb
rubysmith-5.3.0 lib/rubysmith/configuration/transformers/current_time.rb
rubysmith-5.2.0 lib/rubysmith/configuration/transformers/current_time.rb
rubysmith-5.1.0 lib/rubysmith/configuration/transformers/current_time.rb
rubysmith-5.0.1 lib/rubysmith/configuration/transformers/current_time.rb