Sha256: e7665639f3b5ea6ea4191d5253de15442e4dff149f03960ed6ebc4026950124a

Contents?: true

Size: 546 Bytes

Versions: 7

Compression:

Stored size: 546 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 self.class.timestamp_override
    end

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
gotime-cassandra_object-0.8.7 lib/cassandra_object/timestamps.rb
gotime-cassandra_object-0.8.6 lib/cassandra_object/timestamps.rb
gotime-cassandra_object-0.8.5 lib/cassandra_object/timestamps.rb
gotime-cassandra_object-0.8.4 lib/cassandra_object/timestamps.rb
gotime-cassandra_object-0.8.3 lib/cassandra_object/timestamps.rb
gotime-cassandra_object-0.8.2 lib/cassandra_object/timestamps.rb
gotime-cassandra_object-0.8.1 lib/cassandra_object/timestamps.rb