mongoid 2.2.4 → 2.2.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -45,6 +45,7 @@ module Mongoid #:nodoc:
45
45
  #
46
46
  # @return [ true ] True.
47
47
  def remove(options = {})
48
+ return super if embedded? && respond_to?(:version_max) && version_max
48
49
  now = Time.now
49
50
  collection.update({ :_id => id }, { '$set' => { :deleted_at => now } })
50
51
  @attributes["deleted_at"] = now
@@ -59,7 +59,9 @@ module Rails #:nodoc:
59
59
  #
60
60
  initializer "setup database" do
61
61
  config_file = Rails.root.join("config", "mongoid.yml")
62
- if config_file.file?
62
+ # @todo: Durran: Remove extra check when #1291 complete.
63
+ if config_file.file? &&
64
+ YAML.load(ERB.new(File.read(config_file)).result)[Rails.env].values.flatten.any?
63
65
  ::Mongoid.load!(config_file)
64
66
  end
65
67
  end
@@ -232,7 +232,7 @@ module Mongoid # :nodoc:
232
232
  def substitute(replacement)
233
233
  tap do |proxy|
234
234
  if replacement.blank?
235
- if assigning?
235
+ if assigning? && !proxy.empty?
236
236
  base.atomic_unsets.push(proxy.first.atomic_path)
237
237
  end
238
238
  proxy.clear
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module Mongoid #:nodoc
3
- VERSION = "2.2.4"
3
+ VERSION = "2.2.5"
4
4
  end
@@ -47,8 +47,10 @@ module Mongoid #:nodoc:
47
47
  def revise
48
48
  previous = previous_revision
49
49
  if previous && versioned_attributes_changed?
50
- new_version = versions.build(previous.versioned_attributes)
51
- versions.shift if version_max.present? && versions.length > version_max
50
+ versions.build(previous.versioned_attributes)
51
+ if version_max.present? && versions.length > version_max
52
+ versions.delete(versions.first)
53
+ end
52
54
  self.version = (version || 1 ) + 1
53
55
  end
54
56
  end
@@ -62,7 +64,9 @@ module Mongoid #:nodoc:
62
64
  # @since 2.2.1
63
65
  def revise!
64
66
  new_version = versions.build((previous_revision || self).versioned_attributes)
65
- versions.shift if version_max.present? && versions.length > version_max
67
+ if version_max.present? && versions.length > version_max
68
+ versions.delete(versions.first)
69
+ end
66
70
  self.version = (version || 1 ) + 1
67
71
  save
68
72
  end
@@ -167,7 +171,7 @@ module Mongoid #:nodoc:
167
171
  # @since 2.1.0
168
172
  def only_versioned_attributes(hash)
169
173
  {}.tap do |versioned|
170
- hash.except("versions").each_pair do |name, value|
174
+ hash.except("versions", "_id").each_pair do |name, value|
171
175
  field = fields[name]
172
176
  versioned[name] = value if !field || field.versioned?
173
177
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.4
4
+ version: 2.2.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-31 00:00:00.000000000Z
12
+ date: 2011-12-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel
16
- requirement: &70285743605420 !ruby/object:Gem::Requirement
16
+ requirement: &70179270881220 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70285743605420
24
+ version_requirements: *70179270881220
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: tzinfo
27
- requirement: &70285743604460 !ruby/object:Gem::Requirement
27
+ requirement: &70179270880520 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.3.22
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70285743604460
35
+ version_requirements: *70179270880520
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: mongo
38
- requirement: &70285743603500 !ruby/object:Gem::Requirement
38
+ requirement: &70179270895860 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '1.3'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70285743603500
46
+ version_requirements: *70179270895860
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rdoc
49
- requirement: &70285743602700 !ruby/object:Gem::Requirement
49
+ requirement: &70179270894860 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 3.5.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70285743602700
57
+ version_requirements: *70179270894860
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: bson_ext
60
- requirement: &70285743601320 !ruby/object:Gem::Requirement
60
+ requirement: &70179270893840 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '1.3'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70285743601320
68
+ version_requirements: *70179270893840
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: mocha
71
- requirement: &70285743600280 !ruby/object:Gem::Requirement
71
+ requirement: &70179270892380 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 0.9.12
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70285743600280
79
+ version_requirements: *70179270892380
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rspec
82
- requirement: &70285743588060 !ruby/object:Gem::Requirement
82
+ requirement: &70179270890180 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '2.6'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70285743588060
90
+ version_requirements: *70179270890180
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: watchr
93
- requirement: &70285743587280 !ruby/object:Gem::Requirement
93
+ requirement: &70179270889280 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
@@ -98,7 +98,7 @@ dependencies:
98
98
  version: '0.6'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70285743587280
101
+ version_requirements: *70179270889280
102
102
  description: Mongoid is an ODM (Object Document Mapper) Framework for MongoDB, written
103
103
  in Ruby.
104
104
  email:
@@ -385,7 +385,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
385
385
  version: '0'
386
386
  segments:
387
387
  - 0
388
- hash: 1180237711887586276
388
+ hash: 4388686167094388523
389
389
  required_rubygems_version: !ruby/object:Gem::Requirement
390
390
  none: false
391
391
  requirements:
@@ -394,7 +394,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
394
394
  version: 1.3.6
395
395
  requirements: []
396
396
  rubyforge_project: mongoid
397
- rubygems_version: 1.8.6
397
+ rubygems_version: 1.8.10
398
398
  signing_key:
399
399
  specification_version: 3
400
400
  summary: Elegant Persistance in Ruby for MongoDB.