module Dataflow::Nodes::Mixin::AddInternalTimestamp
Add an internal updated_at timestamp to the records.
Public Class Methods
included(base)
click to toggle source
# File lib/dataflow/nodes/mixin/add_internal_timestamp.rb, line 7 def self.included(base) base.class_eval do field :use_internal_timestamp, type: Boolean, default: true field :internal_timestamp_key, type: String, default: '_mojaco_updated_at' end end
Public Instance Methods
add_internal_timestamp(records:)
click to toggle source
Add an internal updated_at timestamp to the records
# File lib/dataflow/nodes/mixin/add_internal_timestamp.rb, line 15 def add_internal_timestamp(records:) return unless use_internal_timestamp return unless internal_timestamp_key.present? updated_at = Time.now records.each do |record| record[internal_timestamp_key] = updated_at end end