lib/paper_trail/version.rb in paper_trail-2.0.2 vs lib/paper_trail/version.rb in paper_trail-2.1.0

- old
+ new

@@ -1,19 +1,19 @@ class Version < ActiveRecord::Base belongs_to :item, :polymorphic => true validates_presence_of :event - scope :with_item_keys, lambda { |item_type, item_id| - where(:item_type => item_type, :item_id => item_id) - } + def self.with_item_keys(item_type, item_id) + scoped(:conditions => { :item_type => item_type, :item_id => item_id }) + end scope :subsequent, lambda { |version| - where(["id > ?", version.is_a?(Version) ? version.id : version]).order("id ASC") + where(["id > ?", version.is_a?(self) ? version.id : version]).order("id ASC") } scope :preceding, lambda { |version| - where(["id < ?", version.is_a?(Version) ? version.id : version]).order("id DESC") + where(["id < ?", version.is_a?(self) ? version.id : version]).order("id DESC") } scope :after, lambda { |timestamp| # TODO: is this :order necessary, considering its presence on the has_many :versions association? where(['created_at > ?', timestamp]).order('created_at ASC, id ASC') @@ -85,10 +85,10 @@ def terminator whodunnit end def sibling_versions - Version.with_item_keys(item_type, item_id) + self.class.with_item_keys(item_type, item_id) end def next sibling_versions.subsequent(self).first end