Sha256: 78aecedfa61175af3e6aafd8505ebc4975d5d1e90436a70e2c7ec8fa9b2df3b1
Contents?: true
Size: 1.5 KB
Versions: 1
Compression:
Stored size: 1.5 KB
Contents
class Skyline::Content::Versioning::Version < ActiveRecord::Base set_table_name "skyline_versions" belongs_to :versionable, :polymorphic => true alias_attribute :current_version, :version alias_attribute :current_author, :author class << self # Increase the version number of the record # add the username as updater. # -- def increase!(record,user) class_name = self.class_name(record) logger.warn("[VERSIONING] -- <#{class_name}: #{record.id}> [INCREASE]") if id = self.connection.select_value("SELECT id FROM #{self.table_name} WHERE versionable_type = '#{class_name}' AND versionable_id = #{record.id} LIMIT 1") self.connection.update "UPDATE #{self.table_name} SET version = version+1, author = '#{user.username.to_s}' WHERE id = #{id}" else self.connection.insert "INSERT INTO #{self.table_name} (versionable_type,versionable_id,version,author) VALUES ('#{class_name}',#{record.id},1,'#{user.username.to_s}')" end end # Remove the version as the original # record has also been removed. # -- def destroy!(record) class_name = self.class_name(record) logger.warn("[VERSIONING] -- <#{class_name}: #{record.id}> [DESTROY]") self.delete_all("versionable_type = '#{class_name}' AND versionable_id = #{record.id}") end protected def class_name(record) record.class.name end end # Version objects SHOULD NOT BE SAVED! def save(*params) return true end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
skylinecms-3.0.7 | lib/skyline/content/versioning/version.rb |