Sha256: 7024b916e569e59404fabbb551570660be84ac8d7af9a8e5958afe37da215bfc

Contents?: true

Size: 524 Bytes

Versions: 3

Compression:

Stored size: 524 Bytes

Contents

module CassandraObject
  module Timestamps
    extend ActiveSupport::Concern

    included do
      class_attribute :timestamp_override

      attribute :created_at, :type => :time_with_zone
      attribute :updated_at, :type => :time_with_zone

      before_create :set_created_at
      before_save :set_updated_at
    end

    def set_created_at
      self.created_at = Time.current unless timestamp_override
    end

    def set_updated_at
      self.updated_at = Time.current unless timestamp_override
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gotime-cassandra_object-2.0.0 lib/cassandra_object/timestamps.rb
gotime-cassandra_object-0.9.1 lib/cassandra_object/timestamps.rb
gotime-cassandra_object-0.9.0 lib/cassandra_object/timestamps.rb