mongoid 2.0.0.rc.2 → 2.0.0.rc.3
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/lib/config/locales/kr.yml +15 -15
- data/lib/mongoid/railtie.rb +3 -1
- data/lib/mongoid/relations/macros.rb +4 -0
- data/lib/mongoid/validations.rb +11 -11
- data/lib/mongoid/validations/associated.rb +3 -1
- data/lib/mongoid/version.rb +1 -1
- data/lib/rails/mongoid.rb +46 -22
- metadata +3 -3
data/lib/config/locales/kr.yml
CHANGED
@@ -8,43 +8,43 @@ kr:
|
|
8
8
|
errors:
|
9
9
|
messages:
|
10
10
|
document_not_found:
|
11
|
-
|
11
|
+
클라스 %{klass}와 id를 %{identifiers} 위한 문서를 찾을수 없습니다.
|
12
12
|
#Document not found for class %{klass} with id(s) %{identifiers}.
|
13
13
|
|
14
14
|
invalid_database:
|
15
|
-
|
15
|
+
데이타베이스가 Mongo::DB이어야 합니다, %{name}이면 안됩니다.
|
16
16
|
#Database should be a Mongo::DB, not %{name}.
|
17
17
|
|
18
18
|
invalid_type:
|
19
|
-
|
19
|
+
데이터 필드가 %{klass} 처럼 정의를 내립니다. 하지만 그것은 %{other}를 %{value} 으로 산출되어 받습니다
|
20
20
|
#Field was defined as a(n) %{klass}, but received a %{other} with
|
21
21
|
#the value %{value}.
|
22
22
|
|
23
23
|
unsupported_version:
|
24
|
-
|
24
|
+
MongoDB %{version} 를 사용할수 없습니다. %{mongo_version} 으로 업그레이드 시켜주세요.
|
25
25
|
#MongoDB %{version} not supported, please upgrade
|
26
26
|
#to %{mongo_version}.
|
27
27
|
|
28
28
|
validations:
|
29
|
-
|
29
|
+
확인할수 없습니다 - %{errors}.
|
30
30
|
#Validation failed - %{errors}.
|
31
31
|
|
32
32
|
invalid_collection:
|
33
|
-
|
33
|
+
%{klass} 를 위한 콜렉션에 접근하는것은 임베디드 문서이게 때문에 허락되지 않습니다. 루트 문서에서 콜렉션을 접근해 주세요
|
34
34
|
#Access to the collection for %{klass} is not allowed since it
|
35
35
|
#is an embedded document, please access a collection from
|
36
36
|
#the root document.
|
37
37
|
|
38
38
|
invalid_field:
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
필드의 정의를 %{name}으로 이름짓는것은 허락되지 않습니다.
|
40
|
+
Mongoid 내부의 속성과 메서드이름이 충돌이 되므로 필드의 정의를 내리지 마세요.
|
41
|
+
어떤이름이 포함되는지 보려면 Document#instance_methods를 사용하세요.
|
42
42
|
#Defining a field named %{name} is not allowed. Do not define
|
43
43
|
#fields that conflict with Mongoid internal attributes or method
|
44
44
|
#names. Use Document#instance_methods to see what names this includes.
|
45
|
-
|
46
|
-
|
47
|
-
|
45
|
+
|
46
|
+
too_many_nested_attribute_records:
|
47
|
+
%{association} 을 위한 내부의 속성을 수용하는것은 %{limit}데이터로 제한되어있습니다.
|
48
48
|
#Accepting nested attributes for %{association} is limited
|
49
49
|
#to %{limit} records.
|
50
50
|
|
@@ -53,13 +53,13 @@ kr:
|
|
53
53
|
#Options for embedded_in association must include inverse_of.
|
54
54
|
|
55
55
|
dependent_only_references_one_or_many:
|
56
|
-
|
56
|
+
공급되는 dependent => destroy|delete 옵션은 오직 references_one 또는 references_many 관련되는것에서만 확인 가능합니다.
|
57
57
|
#The dependent => destroy|delete option that was supplied
|
58
58
|
#is only valid on references_one or references_many associations.
|
59
59
|
|
60
60
|
association_cant_have_inverse_of:
|
61
|
-
|
62
|
-
|
61
|
+
이관련된것에서 inverse_of 처럼 정의내리는것은 허락되지 않습니다.
|
62
|
+
오직 embedded_in 에있는 옵션 또는 array된 references_many 옵션을 사용하세요
|
63
63
|
#Defining an inverse_of on this association is not allowed. Only
|
64
64
|
#use this option on embedded_in or references_many as array.
|
65
65
|
|
data/lib/mongoid/railtie.rb
CHANGED
@@ -81,7 +81,9 @@ module Rails #:nodoc:
|
|
81
81
|
::Rails::Mongoid.load_models(app) unless $rails_rake_task
|
82
82
|
end
|
83
83
|
end
|
84
|
-
|
84
|
+
|
85
|
+
# Set the proper error types for Rails. DocumentNotFound errors should be
|
86
|
+
# 404s and not 500s, validation errors are 422s.
|
85
87
|
initializer "load http errors" do |app|
|
86
88
|
config.after_initialize do
|
87
89
|
ActionDispatch::ShowExceptions.rescue_responses.update({
|
@@ -134,6 +134,7 @@ module Mongoid # :nodoc:
|
|
134
134
|
end
|
135
135
|
end
|
136
136
|
alias :belongs_to_related :referenced_in
|
137
|
+
alias :belongs_to :referenced_in
|
137
138
|
|
138
139
|
# Adds a relational association from a parent Document to many
|
139
140
|
# Documents in another database or collection.
|
@@ -163,6 +164,7 @@ module Mongoid # :nodoc:
|
|
163
164
|
end
|
164
165
|
end
|
165
166
|
alias :has_many_related :references_many
|
167
|
+
alias :has_many :referenced_in
|
166
168
|
|
167
169
|
# Adds a relational many-to-many association between many of this
|
168
170
|
# Document and many of another Document.
|
@@ -190,6 +192,7 @@ module Mongoid # :nodoc:
|
|
190
192
|
reference(meta)
|
191
193
|
end
|
192
194
|
end
|
195
|
+
alias :has_and_belongs_to_many :references_and_referenced_in_many
|
193
196
|
|
194
197
|
# Adds a relational association from the child Document to a Document in
|
195
198
|
# another database or collection.
|
@@ -218,6 +221,7 @@ module Mongoid # :nodoc:
|
|
218
221
|
end
|
219
222
|
end
|
220
223
|
alias :has_one_related :references_one
|
224
|
+
alias :has_one :references_one
|
221
225
|
|
222
226
|
private
|
223
227
|
|
data/lib/mongoid/validations.rb
CHANGED
@@ -32,18 +32,18 @@ module Mongoid #:nodoc:
|
|
32
32
|
def read_attribute_for_validation(attr)
|
33
33
|
relations[attr.to_s] ? send(attr, false, :continue => false) : send(attr)
|
34
34
|
end
|
35
|
-
end
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
36
|
+
# Used to prevent infinite loops in associated validations.
|
37
|
+
#
|
38
|
+
# @example Is the document validated?
|
39
|
+
# document.validated?
|
40
|
+
#
|
41
|
+
# @return [ true, false ] Has the document already been validated?
|
42
|
+
#
|
43
|
+
# @since 2.0.0.rc.2
|
44
|
+
def validated?
|
45
|
+
!!@validated
|
46
|
+
end
|
47
47
|
end
|
48
48
|
|
49
49
|
module ClassMethods #:nodoc:
|
@@ -29,7 +29,9 @@ module Mongoid #:nodoc:
|
|
29
29
|
def validate_each(document, attribute, value)
|
30
30
|
unless document.validated?
|
31
31
|
document.validated = true
|
32
|
-
|
32
|
+
valid = value.to_a.collect { |doc| doc.nil? || doc.valid? }.all?
|
33
|
+
document.validated = false
|
34
|
+
return if valid
|
33
35
|
document.errors.add(attribute, :invalid, options.merge(:value => value))
|
34
36
|
else
|
35
37
|
document.validated = false
|
data/lib/mongoid/version.rb
CHANGED
data/lib/rails/mongoid.rb
CHANGED
@@ -1,33 +1,57 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
module Rails #:nodoc:
|
3
3
|
module Mongoid #:nodoc:
|
4
|
-
|
4
|
+
extend self
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
6
|
+
# Use the application configuration to get every model and require it, so
|
7
|
+
# that indexing and inheritance work in both development and production
|
8
|
+
# with the same results.
|
9
|
+
#
|
10
|
+
# @example Load all the application models.
|
11
|
+
# Rails::Mongoid.load_models(app)
|
12
|
+
#
|
13
|
+
# @param [ Application ] app The rails application.
|
14
|
+
def load_models(app)
|
15
|
+
app.config.paths["app/models"].each do |path|
|
16
|
+
Dir.glob("#{path}/**/*.rb").sort.each do |file|
|
17
|
+
load_model(file.gsub("#{path}/" , "").gsub(".rb", ""))
|
14
18
|
end
|
15
19
|
end
|
20
|
+
end
|
16
21
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
22
|
+
# Recursive function to create all the indexes for the model, then
|
23
|
+
# potentially and subclass of the model since both are still root
|
24
|
+
# documents in the hierarchy.
|
25
|
+
#
|
26
|
+
# Note there is a tricky naming scheme going on here that needs to be
|
27
|
+
# revisisted. Module.descendants vs Class.descendents is way too
|
28
|
+
# confusing.
|
29
|
+
#
|
30
|
+
# @example Index the children.
|
31
|
+
# Rails::Mongoid.index_children(classes)
|
32
|
+
#
|
33
|
+
# @param [ Array<Class> ] children The child model classes.
|
34
|
+
def index_children(children)
|
35
|
+
children.each do |model|
|
36
|
+
Logger.new($stdout).info("Generating indexes for #{model}")
|
37
|
+
model.create_indexes
|
38
|
+
index_children(model.descendants)
|
30
39
|
end
|
31
40
|
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
# I don't want to mock out kernel for unit testing purposes, so added this
|
45
|
+
# method as a convenience.
|
46
|
+
#
|
47
|
+
# @example Load the model.
|
48
|
+
# Mongoid.load_model("/mongoid/behaviour")
|
49
|
+
#
|
50
|
+
# @param [ String ] file The base filename.
|
51
|
+
#
|
52
|
+
# @since 2.0.0.rc.3
|
53
|
+
def load_model(file)
|
54
|
+
require_dependency(file)
|
55
|
+
end
|
32
56
|
end
|
33
57
|
end
|
metadata
CHANGED
@@ -7,8 +7,8 @@ version: !ruby/object:Gem::Version
|
|
7
7
|
- 0
|
8
8
|
- 0
|
9
9
|
- rc
|
10
|
-
-
|
11
|
-
version: 2.0.0.rc.
|
10
|
+
- 3
|
11
|
+
version: 2.0.0.rc.3
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- Durran Jordan
|
@@ -356,7 +356,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
356
356
|
requirements:
|
357
357
|
- - ">="
|
358
358
|
- !ruby/object:Gem::Version
|
359
|
-
hash:
|
359
|
+
hash: -1678984237143289701
|
360
360
|
segments:
|
361
361
|
- 0
|
362
362
|
version: "0"
|