mongoid-history 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -86,7 +86,7 @@ Here is a quick example on how to use this plugin. For more details, please look
86
86
  comment.undo! @user
87
87
 
88
88
  # undo versions 1 - 4
89
- comment.undo! @user, :from => 1, :to => 4
89
+ comment.undo! @user, :from => 4, :to => 1
90
90
 
91
91
  # undo last 3 versions
92
92
  comment.undo! @user, :last => 3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.0.7
@@ -96,13 +96,16 @@ module Mongoid::History
96
96
  if options_or_version.is_a? Hash
97
97
  options = options_or_version
98
98
  if options[:from] && options[:to]
99
- versions = history_tracks.where(:version.in => (options[:from] .. options[:to]).to_a)
99
+ lower = options[:from] >= options[:to] ? options[:to] : options[:from]
100
+ upper = options[:from] < options[:to] ? options[:to] : options[:from]
101
+ versions = history_tracks.where( :version.in => (lower .. upper).to_a )
100
102
  elsif options[:last]
101
- versions = history_tracks.limit(options[:last])
103
+ versions = history_tracks.limit( options[:last] )
102
104
  else
103
105
  raise "Invalid options, please specify (:from / :to) keys or :last key."
104
106
  end
105
107
  else
108
+ options_or_version = options_or_version.to_a if options_or_version.is_a?(Range)
106
109
  version = options_or_version || self.attributes[history_trackable_options[:version_field]]
107
110
  version = [ version ].flatten
108
111
  versions = history_tracks.where(:version.in => version)
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mongoid-history}
8
- s.version = "0.0.6"
8
+ s.version = "0.0.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Aaron Qian"]
@@ -284,7 +284,7 @@ describe Mongoid::History do
284
284
 
285
285
  describe "undo" do
286
286
  it "should recognize :from, :to options" do
287
- @comment.undo! @user, :from => 2, :to => 4
287
+ @comment.undo! @user, :from => 4, :to => 2
288
288
  @comment.title.should == "test"
289
289
  end
290
290
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: mongoid-history
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.6
5
+ version: 0.0.7
6
6
  platform: ruby
7
7
  authors:
8
8
  - Aaron Qian
@@ -167,7 +167,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
167
167
  requirements:
168
168
  - - ">="
169
169
  - !ruby/object:Gem::Version
170
- hash: 1896069804740488378
170
+ hash: -460469172984094198
171
171
  segments:
172
172
  - 0
173
173
  version: "0"