lib/vestal_versions.rb in laserlemon-vestal_versions-0.2.3 vs lib/vestal_versions.rb in laserlemon-vestal_versions-0.2.4
- old
+ new
@@ -1,14 +1,16 @@
+require 'version'
+
module LaserLemon
module VestalVersions
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def versioned
- has_many :versions, :as => :versioned, :class_name => 'VestalVersion', :order => 'versions.number', :dependent => :destroy, :autosave => true do
+ has_many :versions, :as => :versioned, :order => 'versions.number', :dependent => :destroy, :autosave => true do
def current
first(:conditions => {:number => versioned.version})
end
def at(value)
@@ -20,10 +22,10 @@
end
end
def between(from_value, to_value)
from, to = at(from_value), at(to_value)
- return [] unless [from, to].all?{|v| v.is_a?(VestalVersion) }
+ return [] unless [from, to].all?{|v| v.is_a?(Version) }
all(
:conditions => {:number => ([from, to].min.number..[from, to].max.number)},
:order => "versions.number #{(from > to) ? 'DESC' : 'ASC'}"
)
end