Sha256: 57910765d397969ce7e61f9d4a1a54526cd9dc46514f9a339f267ace3b32857f
Contents?: true
Size: 516 Bytes
Versions: 8
Compression:
Stored size: 516 Bytes
Contents
module Dolly module Timestamp def write_timestamps(is_persisted) return unless timestamped? write_attribute(:created_at, Time.now) unless is_persisted write_attribute(:updated_at, Time.now) end def timestamped? respond_to?(:created_at) && respond_to?(:updated_at) end def self.included(base) base.extend(ClassMethods) end module ClassMethods def timestamps! property :created_at, :updated_at, class_name: Time end end end end
Version data entries
8 entries across 8 versions & 1 rubygems