Sha256: fbc6e89017e092b33a5ea8bc710feefb498762702836f2de9032a727d3c4a67c
Contents?: true
Size: 1.09 KB
Versions: 2
Compression:
Stored size: 1.09 KB
Contents
module Irwi::Extensions::Models::WikiPageVersion module ClassMethods end module InstanceMethods def next self.class.first :conditions => ["id > ? AND page_id = ?", id, page_id], :order => 'id ASC' end def previous self.class.first :conditions => ["id < ? AND page_id = ?", id, page_id], :order => 'id DESC' end protected def raise_on_update raise ActiveRecordError.new "Cann't modify existent version" end end def self.included( base ) base.send :extend, Irwi::Extensions::Models::WikiPageVersion::ClassMethods base.send :include, Irwi::Extensions::Models::WikiPageVersion::InstanceMethods base.belongs_to :page, :class_name => Irwi.config.page_class_name base.belongs_to :updator, :class_name => Irwi.config.user_class_name base.before_update :raise_on_update base.named_scope :between, lambda { | first, last | first = first.to_i last = last.to_i first, last = last, first if last < first # Reordering if neeeded { :conditions => [ 'number >= ? AND number <= ?', first, last ] } } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
irwi-0.4.1 | lib/irwi/extensions/models/wiki_page_version.rb |
irwi-0.4.0 | lib/irwi/extensions/models/wiki_page_version.rb |