Sha256: 3a125b513b296604f7eb3365eda05a69c8886c510876e1e279c737374e547ded
Contents?: true
Size: 777 Bytes
Versions: 1
Compression:
Stored size: 777 Bytes
Contents
class Version include MongoMapper::Document include Comparable key :number, Integer key :versioned_type, String key :versioned_id, ObjectId key :changes, Hash timestamps! belongs_to :versioned, :polymorphic => true def changes read_attribute(:changes) end alias_attribute :version, :number def <=>(other) number <=> other.number end def previous find_related(:first, :number => {:$lt => number}, :order => 'number.desc') end def next find_related(:first, :number => {:$gt => number}, :order => 'number.asc') end protected def find_related(*args) options = args.extract_options! params = options.merge(:versioned_id => versioned_id, :versioned_type => versioned_type) self.class.first(params) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
versioned-0.2.1 | lib/version.rb |