Sha256: 3cc8b76f9b220be8ccd598794baa7bf0ae0fcbc34e2f8ebd9a9142a70caed760
Contents?: true
Size: 648 Bytes
Versions: 2
Compression:
Stored size: 648 Bytes
Contents
class Version < ActiveRecord::Base belongs_to :versioned, :polymorphic => true validates_presence_of :versioned, :changes, :number validates_numericality_of :number, :greater_than => 0, :only_integer => true validates_uniqueness_of :number, :scope => ['versioned_type', 'versioned_id'] serialize :changes, Hash before_create :set_number def version number end def <=>(other) number <=> other.number end def <(other) number < other.number end def >(other) number > other.number end private def set_number write_attribute(:number, versioned.version.to_i + 1) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
laserlemon-vestal_versions-0.2.6 | lib/version.rb |
laserlemon-vestal_versions-0.3.0 | lib/version.rb |