module CsvRecord::Timestamps
This module handles the behaviour for setting up document created at timestamp.
Public Class Methods
included(receiver)
click to toggle source
# File lib/csv_record/timestamps.rb, line 6 def self.included(receiver) receiver.class_eval do attr_accessor :created_at, :updated_at before_create do set_created_at end after_update do set_updated_at end end end
Private Instance Methods
__set_created_at__()
click to toggle source
Update the created_at field on the Document
to the current time. This is only called on create.
@example Set the created at time.
person.set_created_at
# File lib/csv_record/timestamps.rb, line 27 def __set_created_at__ if !created_at time = Time.now.utc @created_at = time @updated_at = time end end
Also aliased as: set_created_at
__set_updated_at__()
click to toggle source
Update the created_at field on the Document
to the current time. This is called on each save.
@example Set the updated at time.
person.set_updated_at
# File lib/csv_record/timestamps.rb, line 40 def __set_updated_at__ @updated_at = Time.now.utc end
Also aliased as: set_updated_at