mongoid 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +4 -4
- data/lib/config/locales/{pt-br.yml → pt-BR.yml} +5 -5
- data/lib/config/locales/ru.yml +1 -1
- data/lib/config/locales/zh-CN.yml +2 -0
- data/lib/mongoid.rb +0 -1
- data/lib/mongoid/attributes.rb +9 -6
- data/lib/mongoid/collection.rb +21 -0
- data/lib/mongoid/config.rb +31 -8
- data/lib/mongoid/config/replset_database.rb +32 -2
- data/lib/mongoid/contexts.rb +0 -1
- data/lib/mongoid/contexts/enumerable.rb +73 -36
- data/lib/mongoid/contexts/mongo.rb +5 -12
- data/lib/mongoid/copyable.rb +2 -2
- data/lib/mongoid/criteria.rb +4 -23
- data/lib/mongoid/criterion/exclusion.rb +15 -0
- data/lib/mongoid/criterion/inclusion.rb +1 -1
- data/lib/mongoid/criterion/optional.rb +0 -1
- data/lib/mongoid/criterion/unconvertable.rb +20 -0
- data/lib/mongoid/cursor.rb +3 -3
- data/lib/mongoid/dirty.rb +8 -8
- data/lib/mongoid/document.rb +33 -36
- data/lib/mongoid/extensions.rb +7 -0
- data/lib/mongoid/extensions/object/checks.rb +32 -0
- data/lib/mongoid/extensions/object/conversions.rb +1 -1
- data/lib/mongoid/extensions/object_id/conversions.rb +6 -1
- data/lib/mongoid/extensions/range/conversions.rb +25 -0
- data/lib/mongoid/factory.rb +27 -10
- data/lib/mongoid/field.rb +50 -0
- data/lib/mongoid/fields.rb +42 -7
- data/lib/mongoid/finders.rb +5 -17
- data/lib/mongoid/identity.rb +1 -1
- data/lib/mongoid/inspection.rb +17 -21
- data/lib/mongoid/matchers.rb +6 -2
- data/lib/mongoid/matchers/strategies.rb +2 -2
- data/lib/mongoid/named_scope.rb +1 -1
- data/lib/mongoid/observer.rb +45 -14
- data/lib/mongoid/paranoia.rb +2 -2
- data/lib/mongoid/persistence.rb +2 -2
- data/lib/mongoid/persistence/update.rb +2 -1
- data/lib/mongoid/railtie.rb +3 -5
- data/lib/mongoid/relations.rb +1 -0
- data/lib/mongoid/relations/builders.rb +3 -3
- data/lib/mongoid/relations/builders/embedded/in.rb +1 -1
- data/lib/mongoid/relations/builders/embedded/many.rb +1 -1
- data/lib/mongoid/relations/builders/embedded/one.rb +1 -2
- data/lib/mongoid/relations/builders/referenced/in.rb +0 -3
- data/lib/mongoid/relations/builders/referenced/many.rb +21 -1
- data/lib/mongoid/relations/builders/referenced/one.rb +0 -4
- data/lib/mongoid/relations/embedded/many.rb +1 -17
- data/lib/mongoid/relations/macros.rb +3 -2
- data/lib/mongoid/relations/many.rb +2 -0
- data/lib/mongoid/relations/proxy.rb +1 -1
- data/lib/mongoid/relations/referenced/batch.rb +71 -0
- data/lib/mongoid/relations/referenced/batch/insert.rb +57 -0
- data/lib/mongoid/relations/referenced/many.rb +61 -2
- data/lib/mongoid/serialization.rb +1 -1
- data/lib/mongoid/validations/uniqueness.rb +1 -1
- data/lib/mongoid/version.rb +1 -1
- data/lib/rails/generators/mongoid/config/templates/mongoid.yml +8 -11
- metadata +22 -64
- data/lib/mongoid/contexts/paging.rb +0 -50
@@ -50,7 +50,7 @@ module Mongoid # :nodoc:
|
|
50
50
|
#
|
51
51
|
# @since 2.0.0.rc.6
|
52
52
|
def serialize_relations(attributes = {}, options = {})
|
53
|
-
inclusions = options
|
53
|
+
inclusions = options[:include]
|
54
54
|
relation_names(inclusions).each do |name|
|
55
55
|
metadata = relations[name.to_s]
|
56
56
|
relation = send(metadata.name, false, :eager => true)
|
@@ -45,7 +45,7 @@ module Mongoid #:nodoc:
|
|
45
45
|
end
|
46
46
|
|
47
47
|
Array.wrap(options[:scope]).each do |item|
|
48
|
-
criteria = criteria.where(item => document.attributes[item])
|
48
|
+
criteria = criteria.where(item => document.attributes[item.to_s])
|
49
49
|
end
|
50
50
|
if criteria.exists?
|
51
51
|
document.errors.add(
|
data/lib/mongoid/version.rb
CHANGED
@@ -1,17 +1,9 @@
|
|
1
|
-
defaults: &defaults
|
2
|
-
host: localhost
|
3
|
-
# slaves:
|
4
|
-
# - host: slave1.local
|
5
|
-
# port: 27018
|
6
|
-
# - host: slave2.local
|
7
|
-
# port: 27019
|
8
|
-
|
9
1
|
development:
|
10
|
-
|
2
|
+
host: localhost
|
11
3
|
database: <%= database_name || app_name %>_development
|
12
4
|
|
13
5
|
test:
|
14
|
-
|
6
|
+
host: localhost
|
15
7
|
database: <%= database_name || app_name %>_test
|
16
8
|
|
17
9
|
# set these environment variables on your prod server
|
@@ -20,4 +12,9 @@ production:
|
|
20
12
|
port: <%%= ENV['MONGOID_PORT'] %>
|
21
13
|
username: <%%= ENV['MONGOID_USERNAME'] %>
|
22
14
|
password: <%%= ENV['MONGOID_PASSWORD'] %>
|
23
|
-
database: <%%= ENV['MONGOID_DATABASE'] %>
|
15
|
+
database: <%%= ENV['MONGOID_DATABASE'] %>
|
16
|
+
# slaves:
|
17
|
+
# - host: slave1.local
|
18
|
+
# port: 27018
|
19
|
+
# - host: slave2.local
|
20
|
+
# port: 27019
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 2
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
version: 2.0.1
|
4
|
+
prerelease:
|
5
|
+
version: 2.0.2
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Durran Jordan
|
@@ -14,7 +10,7 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date: 2011-
|
13
|
+
date: 2011-05-22 00:00:00 +02:00
|
18
14
|
default_executable:
|
19
15
|
dependencies:
|
20
16
|
- !ruby/object:Gem::Dependency
|
@@ -24,9 +20,6 @@ dependencies:
|
|
24
20
|
requirements:
|
25
21
|
- - ~>
|
26
22
|
- !ruby/object:Gem::Version
|
27
|
-
segments:
|
28
|
-
- 3
|
29
|
-
- 0
|
30
23
|
version: "3.0"
|
31
24
|
type: :runtime
|
32
25
|
prerelease: false
|
@@ -38,100 +31,65 @@ dependencies:
|
|
38
31
|
requirements:
|
39
32
|
- - ~>
|
40
33
|
- !ruby/object:Gem::Version
|
41
|
-
segments:
|
42
|
-
- 0
|
43
|
-
- 3
|
44
|
-
- 22
|
45
34
|
version: 0.3.22
|
46
35
|
type: :runtime
|
47
36
|
prerelease: false
|
48
37
|
version_requirements: *id002
|
49
|
-
- !ruby/object:Gem::Dependency
|
50
|
-
name: will_paginate
|
51
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
-
none: false
|
53
|
-
requirements:
|
54
|
-
- - ~>
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
segments:
|
57
|
-
- 3
|
58
|
-
- 0
|
59
|
-
- pre
|
60
|
-
version: 3.0.pre
|
61
|
-
type: :runtime
|
62
|
-
prerelease: false
|
63
|
-
version_requirements: *id003
|
64
38
|
- !ruby/object:Gem::Dependency
|
65
39
|
name: mongo
|
66
|
-
requirement: &
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
67
41
|
none: false
|
68
42
|
requirements:
|
69
43
|
- - ~>
|
70
44
|
- !ruby/object:Gem::Version
|
71
|
-
segments:
|
72
|
-
- 1
|
73
|
-
- 3
|
74
45
|
version: "1.3"
|
75
46
|
type: :runtime
|
76
47
|
prerelease: false
|
77
|
-
version_requirements: *
|
48
|
+
version_requirements: *id003
|
78
49
|
- !ruby/object:Gem::Dependency
|
79
50
|
name: bson_ext
|
80
|
-
requirement: &
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
81
52
|
none: false
|
82
53
|
requirements:
|
83
54
|
- - ~>
|
84
55
|
- !ruby/object:Gem::Version
|
85
|
-
segments:
|
86
|
-
- 1
|
87
|
-
- 3
|
88
56
|
version: "1.3"
|
89
57
|
type: :development
|
90
58
|
prerelease: false
|
91
|
-
version_requirements: *
|
59
|
+
version_requirements: *id004
|
92
60
|
- !ruby/object:Gem::Dependency
|
93
61
|
name: mocha
|
94
|
-
requirement: &
|
62
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
95
63
|
none: false
|
96
64
|
requirements:
|
97
65
|
- - "="
|
98
66
|
- !ruby/object:Gem::Version
|
99
|
-
segments:
|
100
|
-
- 0
|
101
|
-
- 9
|
102
|
-
- 8
|
103
67
|
version: 0.9.8
|
104
68
|
type: :development
|
105
69
|
prerelease: false
|
106
|
-
version_requirements: *
|
70
|
+
version_requirements: *id005
|
107
71
|
- !ruby/object:Gem::Dependency
|
108
72
|
name: rspec
|
109
|
-
requirement: &
|
73
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
110
74
|
none: false
|
111
75
|
requirements:
|
112
76
|
- - ~>
|
113
77
|
- !ruby/object:Gem::Version
|
114
|
-
|
115
|
-
- 2
|
116
|
-
- 4
|
117
|
-
version: "2.4"
|
78
|
+
version: "2.6"
|
118
79
|
type: :development
|
119
80
|
prerelease: false
|
120
|
-
version_requirements: *
|
81
|
+
version_requirements: *id006
|
121
82
|
- !ruby/object:Gem::Dependency
|
122
83
|
name: watchr
|
123
|
-
requirement: &
|
84
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
124
85
|
none: false
|
125
86
|
requirements:
|
126
87
|
- - "="
|
127
88
|
- !ruby/object:Gem::Version
|
128
|
-
segments:
|
129
|
-
- 0
|
130
|
-
- 6
|
131
89
|
version: "0.6"
|
132
90
|
type: :development
|
133
91
|
prerelease: false
|
134
|
-
version_requirements: *
|
92
|
+
version_requirements: *id007
|
135
93
|
description: Mongoid is an ODM (Object Document Mapper) Framework for MongoDB, written in Ruby.
|
136
94
|
email:
|
137
95
|
- durran@gmail.com
|
@@ -154,7 +112,7 @@ files:
|
|
154
112
|
- lib/config/locales/kr.yml
|
155
113
|
- lib/config/locales/nl.yml
|
156
114
|
- lib/config/locales/pl.yml
|
157
|
-
- lib/config/locales/pt-
|
115
|
+
- lib/config/locales/pt-BR.yml
|
158
116
|
- lib/config/locales/pt.yml
|
159
117
|
- lib/config/locales/ro.yml
|
160
118
|
- lib/config/locales/ru.yml
|
@@ -179,7 +137,6 @@ files:
|
|
179
137
|
- lib/mongoid/contexts/enumerable/sort.rb
|
180
138
|
- lib/mongoid/contexts/enumerable.rb
|
181
139
|
- lib/mongoid/contexts/mongo.rb
|
182
|
-
- lib/mongoid/contexts/paging.rb
|
183
140
|
- lib/mongoid/contexts.rb
|
184
141
|
- lib/mongoid/copyable.rb
|
185
142
|
- lib/mongoid/criteria.rb
|
@@ -191,6 +148,7 @@ files:
|
|
191
148
|
- lib/mongoid/criterion/inspection.rb
|
192
149
|
- lib/mongoid/criterion/optional.rb
|
193
150
|
- lib/mongoid/criterion/selector.rb
|
151
|
+
- lib/mongoid/criterion/unconvertable.rb
|
194
152
|
- lib/mongoid/cursor.rb
|
195
153
|
- lib/mongoid/default_scope.rb
|
196
154
|
- lib/mongoid/dirty.rb
|
@@ -222,11 +180,13 @@ files:
|
|
222
180
|
- lib/mongoid/extensions/hash/scoping.rb
|
223
181
|
- lib/mongoid/extensions/integer/conversions.rb
|
224
182
|
- lib/mongoid/extensions/nil/collectionization.rb
|
183
|
+
- lib/mongoid/extensions/object/checks.rb
|
225
184
|
- lib/mongoid/extensions/object/conversions.rb
|
226
185
|
- lib/mongoid/extensions/object/reflections.rb
|
227
186
|
- lib/mongoid/extensions/object/yoda.rb
|
228
187
|
- lib/mongoid/extensions/object_id/conversions.rb
|
229
188
|
- lib/mongoid/extensions/proc/scoping.rb
|
189
|
+
- lib/mongoid/extensions/range/conversions.rb
|
230
190
|
- lib/mongoid/extensions/set/conversions.rb
|
231
191
|
- lib/mongoid/extensions/string/conversions.rb
|
232
192
|
- lib/mongoid/extensions/string/inflections.rb
|
@@ -332,6 +292,8 @@ files:
|
|
332
292
|
- lib/mongoid/relations/one.rb
|
333
293
|
- lib/mongoid/relations/polymorphic.rb
|
334
294
|
- lib/mongoid/relations/proxy.rb
|
295
|
+
- lib/mongoid/relations/referenced/batch/insert.rb
|
296
|
+
- lib/mongoid/relations/referenced/batch.rb
|
335
297
|
- lib/mongoid/relations/referenced/in.rb
|
336
298
|
- lib/mongoid/relations/referenced/many.rb
|
337
299
|
- lib/mongoid/relations/referenced/many_to_many.rb
|
@@ -379,7 +341,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
379
341
|
requirements:
|
380
342
|
- - ">="
|
381
343
|
- !ruby/object:Gem::Version
|
382
|
-
hash: -
|
344
|
+
hash: -1675372981513058867
|
383
345
|
segments:
|
384
346
|
- 0
|
385
347
|
version: "0"
|
@@ -388,15 +350,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
388
350
|
requirements:
|
389
351
|
- - ">="
|
390
352
|
- !ruby/object:Gem::Version
|
391
|
-
segments:
|
392
|
-
- 1
|
393
|
-
- 3
|
394
|
-
- 6
|
395
353
|
version: 1.3.6
|
396
354
|
requirements: []
|
397
355
|
|
398
356
|
rubyforge_project: mongoid
|
399
|
-
rubygems_version: 1.
|
357
|
+
rubygems_version: 1.6.2
|
400
358
|
signing_key:
|
401
359
|
specification_version: 3
|
402
360
|
summary: Elegant Persistance in Ruby for MongoDB.
|
@@ -1,50 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
module Mongoid #:nodoc:
|
3
|
-
module Contexts #:nodoc:
|
4
|
-
module Paging
|
5
|
-
# Paginates the documents.
|
6
|
-
#
|
7
|
-
# Example:
|
8
|
-
#
|
9
|
-
# <tt>context.paginate(:page => 6, :per_page => 25)</tt>
|
10
|
-
#
|
11
|
-
# Returns:
|
12
|
-
#
|
13
|
-
# A collection of documents paginated.
|
14
|
-
# All previous <tt>limit</tt> and <tt>skip</tt> call will be ignored.
|
15
|
-
def paginate(pager_options={})
|
16
|
-
if pager_options[:per_page]
|
17
|
-
options[:limit] = pager_options[:per_page].to_i
|
18
|
-
if pager_options[:page]
|
19
|
-
options[:skip] = (pager_options[:page].to_i - 1) * pager_options[:per_page].to_i
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
@collection ||= execute(true)
|
24
|
-
WillPaginate::Collection.create(page, per_page, count) do |pager|
|
25
|
-
pager.replace(@collection.to_a)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
# Either returns the page option and removes it from the options, or
|
30
|
-
# returns a default value of 1.
|
31
|
-
#
|
32
|
-
# Returns:
|
33
|
-
#
|
34
|
-
# An +Integer+ page number.
|
35
|
-
def page
|
36
|
-
skips, limits = options[:skip], options[:limit]
|
37
|
-
(skips && limits) ? (skips + limits) / limits : 1
|
38
|
-
end
|
39
|
-
|
40
|
-
# Get the number of results per page or the default of 20.
|
41
|
-
#
|
42
|
-
# Returns:
|
43
|
-
#
|
44
|
-
# The +Integer+ number of documents in each page.
|
45
|
-
def per_page
|
46
|
-
(options[:limit] || 20).to_i
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|