Sha256: 95723e4176b9ddf899e639e475d19f53bfaee4ef32613dcd388cbf702675d673

Contents?: true

Size: 588 Bytes

Versions: 1

Compression:

Stored size: 588 Bytes

Contents

# frozen_string_literal: true

require "dry/transformer/all"
require "dry/transformer/registry"

module ROM
  class Changeset
    # Dry::Transformer Registry useful for pipe
    #
    # @api private
    module PipeRegistry
      extend Dry::Transformer::Registry

      import Dry::Transformer::Coercions
      import Dry::Transformer::HashTransformations

      def self.add_timestamps(data)
        now = Time.now
        Hash(created_at: now, updated_at: now).merge(data)
      end

      def self.touch(data)
        Hash(updated_at: Time.now).merge(data)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rom-6.0.0.alpha1 lib/rom/changeset/pipe_registry.rb