mongo_mapper_versioned 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@
2
2
  module MongoMapper
3
3
  module Plugins
4
4
  module Versioned
5
- Version = '0.1.6'
5
+ Version = '0.1.7'
6
6
  end
7
7
  end
8
8
  end
@@ -11,7 +11,7 @@ module MongoMapper
11
11
  many :versions, :class => MongoMapper::Plugins::Versioned::Version, :foreign_key => :versioned_id, :dependent => :destroy, :order => :version_number.asc
12
12
 
13
13
  after_create :create_version
14
- after_update :create_version, :if => Proc.new{ |doc| doc.should_create_version? || doc.should_create_initial_version? }
14
+ before_update :create_version, :if => Proc.new{ |doc| doc.should_create_version? }
15
15
 
16
16
  define_method "ignored_keys" do
17
17
  configuration[:ignored_keys]
@@ -24,7 +24,7 @@ module MongoMapper
24
24
  module InstanceMethods
25
25
 
26
26
  def create_version
27
- self.version_number = versions.empty? ? 1 : versions.last.version_number+1
27
+ self.version_number = self.versions.empty? ? 1 : self.versions.last.version_number+1
28
28
  self.versions << current_version
29
29
  end
30
30
 
@@ -48,11 +48,7 @@ module MongoMapper
48
48
  def version_at(target_version_number)
49
49
  versions.where(:version_number => target_version_number).first
50
50
  end
51
-
52
- def should_create_initial_version?
53
- versions.empty?
54
- end
55
-
51
+
56
52
  # this method might be overwritten
57
53
  # by something more sophisticated (esp. in case of EmbeddedDocuments)
58
54
  def should_create_version?
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongo_mapper_versioned
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 6
10
- version: 0.1.6
9
+ - 7
10
+ version: 0.1.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tomas Celizna