mongoid 2.1.4 → 2.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mongoid/atomic/modifiers.rb +1 -0
- data/lib/mongoid/railties/database.rake +1 -1
- data/lib/mongoid/relations.rb +4 -4
- data/lib/mongoid/relations/embedded/many.rb +2 -2
- data/lib/mongoid/relations/many.rb +2 -1
- data/lib/mongoid/relations/proxy.rb +1 -1
- data/lib/mongoid/version.rb +1 -1
- data/lib/rails/mongoid.rb +39 -17
- metadata +19 -19
@@ -79,7 +79,7 @@ namespace :db do
|
|
79
79
|
|
80
80
|
desc 'Create the indexes defined on your mongoid models'
|
81
81
|
task :create_indexes => :environment do
|
82
|
-
::Rails::Mongoid.
|
82
|
+
::Rails::Mongoid.create_indexes("app/models/**/*.rb")
|
83
83
|
end
|
84
84
|
|
85
85
|
def convert_ids(obj)
|
data/lib/mongoid/relations.rb
CHANGED
@@ -69,7 +69,7 @@ module Mongoid # :nodoc:
|
|
69
69
|
#
|
70
70
|
# @since 2.0.0.rc.1
|
71
71
|
def embedded_many?
|
72
|
-
|
72
|
+
metadata && metadata.macro == :embeds_many
|
73
73
|
end
|
74
74
|
|
75
75
|
# Determine if the document is part of an embeds_one relation.
|
@@ -81,7 +81,7 @@ module Mongoid # :nodoc:
|
|
81
81
|
#
|
82
82
|
# @since 2.0.0.rc.1
|
83
83
|
def embedded_one?
|
84
|
-
|
84
|
+
metadata && metadata.macro == :embeds_one
|
85
85
|
end
|
86
86
|
|
87
87
|
# Determine if the document is part of an references_many relation.
|
@@ -93,7 +93,7 @@ module Mongoid # :nodoc:
|
|
93
93
|
#
|
94
94
|
# @since 2.0.0.rc.1
|
95
95
|
def referenced_many?
|
96
|
-
|
96
|
+
metadata && metadata.macro == :references_many
|
97
97
|
end
|
98
98
|
|
99
99
|
# Determine if the document is part of an references_one relation.
|
@@ -105,7 +105,7 @@ module Mongoid # :nodoc:
|
|
105
105
|
#
|
106
106
|
# @since 2.0.0.rc.1
|
107
107
|
def referenced_one?
|
108
|
-
|
108
|
+
metadata && metadata.macro == :references_one
|
109
109
|
end
|
110
110
|
end
|
111
111
|
end
|
@@ -124,8 +124,8 @@ module Mongoid # :nodoc:
|
|
124
124
|
def delete(document)
|
125
125
|
target.delete_one(document).tap do |doc|
|
126
126
|
if doc && !binding?
|
127
|
-
unbind_one(doc)
|
128
127
|
doc.delete(:suppress => true)
|
128
|
+
unbind_one(doc)
|
129
129
|
end
|
130
130
|
reindex
|
131
131
|
end
|
@@ -374,8 +374,8 @@ module Mongoid # :nodoc:
|
|
374
374
|
criteria.size.tap do
|
375
375
|
criteria.each do |doc|
|
376
376
|
target.delete_one(doc)
|
377
|
-
unbind_one(doc)
|
378
377
|
doc.send(method, :suppress => true)
|
378
|
+
unbind_one(doc)
|
379
379
|
end
|
380
380
|
reindex
|
381
381
|
end
|
@@ -80,7 +80,8 @@ module Mongoid #:nodoc:
|
|
80
80
|
#
|
81
81
|
# @since 2.0.0
|
82
82
|
def respond_to?(name, include_private = false)
|
83
|
-
[].respond_to?(name, include_private) ||
|
83
|
+
[].respond_to?(name, include_private) ||
|
84
|
+
klass.respond_to?(name, include_private) || super
|
84
85
|
end
|
85
86
|
|
86
87
|
# This is public access to the relation's criteria.
|
@@ -9,7 +9,7 @@ module Mongoid # :nodoc:
|
|
9
9
|
# We undefine most methods to get them sent through to the target.
|
10
10
|
instance_methods.each do |method|
|
11
11
|
undef_method(method) unless
|
12
|
-
method =~ /(^__|^send$|^object_id$|^extend$|^tap$)/
|
12
|
+
method =~ /(^__|^send$|^object_id$|^extend$|^respond_to\?$|^tap$)/
|
13
13
|
end
|
14
14
|
|
15
15
|
attr_accessor :base, :loaded, :metadata, :target
|
data/lib/mongoid/version.rb
CHANGED
data/lib/rails/mongoid.rb
CHANGED
@@ -3,23 +3,24 @@ module Rails #:nodoc:
|
|
3
3
|
module Mongoid #:nodoc:
|
4
4
|
extend self
|
5
5
|
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
# @
|
15
|
-
#
|
16
|
-
#
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
6
|
+
# Create indexes for each model given the provided pattern and the class is
|
7
|
+
# not embedded.
|
8
|
+
#
|
9
|
+
# @example Create all the indexes.
|
10
|
+
# Rails::Mongoid.create_indexes("app/models/**/*.rb")
|
11
|
+
#
|
12
|
+
# @param [ String ] pattern The file matching pattern.
|
13
|
+
#
|
14
|
+
# @return [ Array<String> ] The file names.
|
15
|
+
#
|
16
|
+
# @since 2.1.0
|
17
|
+
def create_indexes(pattern)
|
18
|
+
Dir.glob(pattern).each do |file|
|
19
|
+
model = determine_model(file)
|
20
|
+
if model
|
21
|
+
Logger.new($stdout).info("Generating indexes for #{model}")
|
22
|
+
model.create_indexes
|
23
|
+
end
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
@@ -54,5 +55,26 @@ module Rails #:nodoc:
|
|
54
55
|
def load_model(file)
|
55
56
|
require_dependency(file)
|
56
57
|
end
|
58
|
+
|
59
|
+
# Given the provided file name, determine the model and return the class.
|
60
|
+
#
|
61
|
+
# @example Determine the model from the file.
|
62
|
+
# Rails::Mongoid.determine_model("app/models/person.rb")
|
63
|
+
#
|
64
|
+
# @param [ String ] file The filename.
|
65
|
+
#
|
66
|
+
# @return [ Class ] The model.
|
67
|
+
#
|
68
|
+
# @since 2.1.0
|
69
|
+
def determine_model(file)
|
70
|
+
model_path = file[0..-4].split('/')[2..-1]
|
71
|
+
begin
|
72
|
+
klass = model_path.map { |path| path.camelize }.join('::').constantize
|
73
|
+
if klass.ancestors.include?(::Mongoid::Document) && !klass.embedded
|
74
|
+
return klass
|
75
|
+
end
|
76
|
+
rescue => e
|
77
|
+
end
|
78
|
+
end
|
57
79
|
end
|
58
80
|
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.1.
|
4
|
+
version: 2.1.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-08-
|
12
|
+
date: 2011-08-05 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
16
|
-
requirement: &
|
16
|
+
requirement: &70194026936900 !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: *70194026936900
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: tzinfo
|
27
|
-
requirement: &
|
27
|
+
requirement: &70194026936180 !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: *70194026936180
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: mongo
|
38
|
-
requirement: &
|
38
|
+
requirement: &70194026935100 !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: *70194026935100
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rdoc
|
49
|
-
requirement: &
|
49
|
+
requirement: &70194026934200 !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: *70194026934200
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: bson_ext
|
60
|
-
requirement: &
|
60
|
+
requirement: &70194026933020 !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: *70194026933020
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: mocha
|
71
|
-
requirement: &
|
71
|
+
requirement: &70194026932080 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 0.9.8
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70194026932080
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rspec
|
82
|
-
requirement: &
|
82
|
+
requirement: &70194026931080 !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: *70194026931080
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: watchr
|
93
|
-
requirement: &
|
93
|
+
requirement: &70194026929800 !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: *70194026929800
|
102
102
|
description: Mongoid is an ODM (Object Document Mapper) Framework for MongoDB, written
|
103
103
|
in Ruby.
|
104
104
|
email:
|
@@ -378,7 +378,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
378
378
|
version: '0'
|
379
379
|
segments:
|
380
380
|
- 0
|
381
|
-
hash:
|
381
|
+
hash: 3142306228316146123
|
382
382
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
383
383
|
none: false
|
384
384
|
requirements:
|