Sha256: 16ce5218229d79c0a4af6bc04e4c2ae796820cba14fc1bcea89151654b43146b

Contents?: true

Size: 693 Bytes

Versions: 1

Compression:

Stored size: 693 Bytes

Contents

module HasTimestamps
  class Timestamp < ActiveRecord::Base
    class << self
      def create_table
        self.connection.create_table(:timestamps) do |t|
          t.integer :timestampable_id
          t.string  :timestampable_type
          t.string  :key
          t.datetime    :stamped_at
          t.timestamps
        end
      end

      def drop_table
        self.connection.drop_table(:timestamps)
      end
    end

    belongs_to :timestampable, :polymorphic => true

    validates_presence_of :key, :timestampable_id, :timestampable_type
    validates_uniqueness_of :key, :scope => [ :timestampable_id, :timestampable_type ]

    def to_param
      self.key
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
seamusabshere-has_timestamps-1.5.4 lib/timestamp.rb