mongoid 2.2.4 → 2.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mongoid/paranoia.rb +1 -0
- data/lib/mongoid/railtie.rb +3 -1
- data/lib/mongoid/relations/embedded/many.rb +1 -1
- data/lib/mongoid/version.rb +1 -1
- data/lib/mongoid/versioning.rb +8 -4
- metadata +20 -20
data/lib/mongoid/paranoia.rb
CHANGED
@@ -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
|
data/lib/mongoid/railtie.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/mongoid/version.rb
CHANGED
data/lib/mongoid/versioning.rb
CHANGED
@@ -47,8 +47,10 @@ module Mongoid #:nodoc:
|
|
47
47
|
def revise
|
48
48
|
previous = previous_revision
|
49
49
|
if previous && versioned_attributes_changed?
|
50
|
-
|
51
|
-
|
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
|
-
|
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
|
+
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-
|
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: &
|
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: *
|
24
|
+
version_requirements: *70179270881220
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: tzinfo
|
27
|
-
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: *
|
35
|
+
version_requirements: *70179270880520
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: mongo
|
38
|
-
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: *
|
46
|
+
version_requirements: *70179270895860
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rdoc
|
49
|
-
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: *
|
57
|
+
version_requirements: *70179270894860
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: bson_ext
|
60
|
-
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: *
|
68
|
+
version_requirements: *70179270893840
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: mocha
|
71
|
-
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: *
|
79
|
+
version_requirements: *70179270892380
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rspec
|
82
|
-
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: *
|
90
|
+
version_requirements: *70179270890180
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: watchr
|
93
|
-
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: *
|
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:
|
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.
|
397
|
+
rubygems_version: 1.8.10
|
398
398
|
signing_key:
|
399
399
|
specification_version: 3
|
400
400
|
summary: Elegant Persistance in Ruby for MongoDB.
|