Sha256: d51b0eebeaa7e85fb2fb32fb8770de0ded21e34ec4d6dd09521a089d2d77c8e6
Contents?: true
Size: 672 Bytes
Versions: 1
Compression:
Stored size: 672 Bytes
Contents
class VestalVersion < 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.versions.maximum(:number).to_i + 1) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
laserlemon-vestal_versions-0.2.2 | lib/version.rb |