mongoid-pre 2.0.0.beta1 → 2.0.0.pre
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/.watchr +15 -10
- data/HISTORY +342 -0
- data/README.rdoc +8 -1
- data/Rakefile +2 -3
- data/VERSION +1 -1
- data/lib/mongoid/associations/{embedded_in.rb → belongs_to.rb} +4 -4
- data/lib/mongoid/associations/belongs_to_related.rb +9 -6
- data/lib/mongoid/associations/{embeds_many.rb → has_many.rb} +20 -33
- data/lib/mongoid/associations/has_many_related.rb +4 -28
- data/lib/mongoid/associations/{embeds_one.rb → has_one.rb} +6 -6
- data/lib/mongoid/associations/options.rb +6 -1
- data/lib/mongoid/associations.rb +32 -41
- data/lib/mongoid/attributes.rb +6 -13
- data/lib/mongoid/collection.rb +1 -2
- data/lib/mongoid/commands/delete.rb +1 -1
- data/lib/mongoid/commands/delete_all.rb +1 -4
- data/lib/mongoid/commands/destroy.rb +1 -1
- data/lib/mongoid/commands/destroy_all.rb +1 -3
- data/lib/mongoid/commands/save.rb +0 -1
- data/lib/mongoid/commands.rb +13 -2
- data/lib/mongoid/components.rb +1 -6
- data/lib/mongoid/config.rb +1 -5
- data/lib/mongoid/contexts/enumerable.rb +17 -54
- data/lib/mongoid/contexts/mongo.rb +38 -101
- data/lib/mongoid/contexts/paging.rb +2 -2
- data/lib/mongoid/contexts.rb +0 -21
- data/lib/mongoid/criteria.rb +73 -15
- data/lib/mongoid/criterion/inclusion.rb +0 -2
- data/lib/mongoid/criterion/optional.rb +2 -10
- data/lib/mongoid/document.rb +30 -41
- data/lib/mongoid/extensions.rb +0 -15
- data/lib/mongoid/field.rb +7 -20
- data/lib/mongoid/fields.rb +10 -15
- data/lib/mongoid/finders.rb +98 -10
- data/lib/mongoid/identity.rb +2 -8
- data/lib/mongoid/named_scope.rb +0 -2
- data/lib/mongoid/validations/associated.rb +8 -3
- data/lib/mongoid/validations/uniqueness.rb +7 -2
- data/lib/mongoid/validations.rb +2 -2
- data/lib/mongoid/versioning.rb +1 -1
- data/lib/mongoid.rb +5 -21
- data/mongoid.gemspec +19 -59
- data/spec/integration/mongoid/associations_spec.rb +3 -42
- data/spec/integration/mongoid/attributes_spec.rb +2 -2
- data/spec/integration/mongoid/commands_spec.rb +13 -27
- data/spec/integration/mongoid/contexts/enumerable_spec.rb +0 -13
- data/spec/integration/mongoid/criteria_spec.rb +3 -50
- data/spec/integration/mongoid/document_spec.rb +5 -72
- data/spec/integration/mongoid/finders_spec.rb +28 -85
- data/spec/models/address.rb +3 -3
- data/spec/models/animal.rb +2 -2
- data/spec/models/country_code.rb +2 -2
- data/spec/models/game.rb +1 -2
- data/spec/models/inheritance.rb +5 -5
- data/spec/models/location.rb +2 -2
- data/spec/models/name.rb +3 -3
- data/spec/models/namespacing.rb +2 -2
- data/spec/models/patient.rb +0 -2
- data/spec/models/person.rb +4 -6
- data/spec/models/pet.rb +3 -3
- data/spec/models/pet_owner.rb +3 -3
- data/spec/models/phone.rb +3 -3
- data/spec/models/post.rb +1 -1
- data/spec/models/translation.rb +2 -2
- data/spec/models/vet_visit.rb +2 -2
- data/spec/spec_helper.rb +2 -2
- data/spec/unit/mongoid/associations/belongs_to_related_spec.rb +0 -4
- data/spec/unit/mongoid/associations/{embedded_in_spec.rb → belongs_to_spec.rb} +11 -11
- data/spec/unit/mongoid/associations/has_many_related_spec.rb +14 -45
- data/spec/unit/mongoid/associations/{embeds_many_spec.rb → has_many_spec.rb} +34 -79
- data/spec/unit/mongoid/associations/{embeds_one_spec.rb → has_one_spec.rb} +18 -18
- data/spec/unit/mongoid/associations/options_spec.rb +19 -20
- data/spec/unit/mongoid/associations_spec.rb +12 -74
- data/spec/unit/mongoid/attributes_spec.rb +51 -83
- data/spec/unit/mongoid/collection_spec.rb +0 -46
- data/spec/unit/mongoid/commands/delete_all_spec.rb +8 -9
- data/spec/unit/mongoid/commands/delete_spec.rb +3 -6
- data/spec/unit/mongoid/commands/destroy_all_spec.rb +2 -0
- data/spec/unit/mongoid/commands/destroy_spec.rb +3 -10
- data/spec/unit/mongoid/commands_spec.rb +11 -20
- data/spec/unit/mongoid/config_spec.rb +0 -18
- data/spec/unit/mongoid/contexts/enumerable_spec.rb +11 -198
- data/spec/unit/mongoid/contexts/mongo_spec.rb +54 -357
- data/spec/unit/mongoid/criteria_spec.rb +78 -107
- data/spec/unit/mongoid/criterion/exclusion_spec.rb +13 -3
- data/spec/unit/mongoid/criterion/inclusion_spec.rb +19 -25
- data/spec/unit/mongoid/criterion/optional_spec.rb +18 -25
- data/spec/unit/mongoid/document_spec.rb +34 -71
- data/spec/unit/mongoid/extensions/array/conversions_spec.rb +2 -2
- data/spec/unit/mongoid/extensions/datetime/conversions_spec.rb +3 -0
- data/spec/unit/mongoid/extensions/object/conversions_spec.rb +2 -16
- data/spec/unit/mongoid/extensions/proc/scoping_spec.rb +1 -1
- data/spec/unit/mongoid/field_spec.rb +0 -62
- data/spec/unit/mongoid/fields_spec.rb +0 -33
- data/spec/unit/mongoid/finders_spec.rb +1 -37
- data/spec/unit/mongoid/identity_spec.rb +6 -47
- data/spec/unit/mongoid/named_scope_spec.rb +2 -15
- data/spec/unit/mongoid/scope_spec.rb +1 -1
- data/spec/unit/mongoid/validations/uniqueness_spec.rb +3 -3
- data/spec/unit/mongoid_spec.rb +2 -11
- metadata +14 -64
- data/lib/mongoid/associations/meta_data.rb +0 -28
- data/lib/mongoid/contexts/ids.rb +0 -25
- data/lib/mongoid/deprecation.rb +0 -22
- data/lib/mongoid/dirty.rb +0 -203
- data/lib/mongoid/extensions/big_decimal/conversions.rb +0 -19
- data/lib/mongoid/extensions/binary/conversions.rb +0 -17
- data/lib/mongoid/extensions/objectid/conversions.rb +0 -15
- data/lib/mongoid/extras.rb +0 -61
- data/lib/mongoid/javascript/functions.yml +0 -37
- data/lib/mongoid/javascript.rb +0 -21
- data/lib/mongoid/observable.rb +0 -30
- data/lib/mongoid/paths.rb +0 -54
- data/lib/mongoid/persistence/command.rb +0 -20
- data/lib/mongoid/persistence/insert.rb +0 -71
- data/lib/mongoid/persistence/update.rb +0 -78
- data/lib/mongoid/persistence.rb +0 -27
- data/lib/mongoid/state.rb +0 -32
- data/spec/integration/mongoid/dirty_spec.rb +0 -70
- data/spec/integration/mongoid/persistence/update_spec.rb +0 -46
- data/spec/models/callbacks.rb +0 -18
- data/spec/unit/mongoid/associations/meta_data_spec.rb +0 -88
- data/spec/unit/mongoid/contexts_spec.rb +0 -25
- data/spec/unit/mongoid/deprecation_spec.rb +0 -24
- data/spec/unit/mongoid/dirty_spec.rb +0 -286
- data/spec/unit/mongoid/extensions/big_decimal/conversions_spec.rb +0 -22
- data/spec/unit/mongoid/extensions/binary/conversions_spec.rb +0 -22
- data/spec/unit/mongoid/extras_spec.rb +0 -102
- data/spec/unit/mongoid/javascript_spec.rb +0 -48
- data/spec/unit/mongoid/observable_spec.rb +0 -46
- data/spec/unit/mongoid/paths_spec.rb +0 -124
- data/spec/unit/mongoid/persistence/insert_spec.rb +0 -175
- data/spec/unit/mongoid/persistence/update_spec.rb +0 -148
- data/spec/unit/mongoid/persistence_spec.rb +0 -40
- data/spec/unit/mongoid/state_spec.rb +0 -83
data/lib/mongoid/field.rb
CHANGED
|
@@ -1,25 +1,11 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
module Mongoid #:nodoc:
|
|
3
3
|
class Field
|
|
4
|
-
attr_reader :name, :type
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
# true if accessible, false if not.
|
|
11
|
-
def accessible?
|
|
12
|
-
!!@accessible
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
# Get the default value for the field.
|
|
16
|
-
#
|
|
17
|
-
# Returns:
|
|
18
|
-
#
|
|
19
|
-
# The primitive value or a copy of the default.
|
|
20
|
-
def default
|
|
21
|
-
(@default.is_a?(Array) || @default.is_a?(Hash)) ? @default.dup : @default
|
|
22
|
-
end
|
|
5
|
+
attr_reader \
|
|
6
|
+
:default,
|
|
7
|
+
:name,
|
|
8
|
+
:type
|
|
23
9
|
|
|
24
10
|
# Create the new field with a name and optional additional options. Valid
|
|
25
11
|
# options are :default
|
|
@@ -33,9 +19,9 @@ module Mongoid #:nodoc:
|
|
|
33
19
|
#
|
|
34
20
|
# <tt>Field.new(:score, :default => 0)</tt>
|
|
35
21
|
def initialize(name, options = {})
|
|
36
|
-
@name
|
|
22
|
+
@name = name
|
|
23
|
+
@default = options[:default]
|
|
37
24
|
@type = options[:type] || String
|
|
38
|
-
@accessible = options.has_key?(:accessible) ? options[:accessible] : true
|
|
39
25
|
end
|
|
40
26
|
|
|
41
27
|
# Used for setting an object in the attributes hash. If nil is provided the
|
|
@@ -48,5 +34,6 @@ module Mongoid #:nodoc:
|
|
|
48
34
|
def get(object)
|
|
49
35
|
type.get(object)
|
|
50
36
|
end
|
|
37
|
+
|
|
51
38
|
end
|
|
52
39
|
end
|
data/lib/mongoid/fields.rb
CHANGED
|
@@ -5,9 +5,11 @@ module Mongoid #:nodoc
|
|
|
5
5
|
included do
|
|
6
6
|
# Set up the class attributes that must be available to all subclasses.
|
|
7
7
|
# These include defaults, fields
|
|
8
|
-
class_inheritable_accessor :fields
|
|
8
|
+
class_inheritable_accessor :defaults, :fields
|
|
9
9
|
|
|
10
|
+
self.defaults = {}
|
|
10
11
|
self.fields = {}
|
|
12
|
+
|
|
11
13
|
delegate :defaults, :fields, :to => "self.class"
|
|
12
14
|
end
|
|
13
15
|
|
|
@@ -27,15 +29,7 @@ module Mongoid #:nodoc
|
|
|
27
29
|
def field(name, options = {})
|
|
28
30
|
access = name.to_s
|
|
29
31
|
set_field(access, options)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
# Returns the default values for the fields on the document
|
|
33
|
-
def defaults
|
|
34
|
-
fields.inject({}) do |defs,(field_name,field)|
|
|
35
|
-
next(defs) if field.default.nil?
|
|
36
|
-
defs[field_name.to_s] = field.default
|
|
37
|
-
defs
|
|
38
|
-
end
|
|
32
|
+
set_default(access, options)
|
|
39
33
|
end
|
|
40
34
|
|
|
41
35
|
protected
|
|
@@ -44,19 +38,20 @@ module Mongoid #:nodoc
|
|
|
44
38
|
meth = options.delete(:as) || name
|
|
45
39
|
fields[name] = Field.new(name, options)
|
|
46
40
|
create_accessors(name, meth, options)
|
|
47
|
-
add_dirty_methods(name)
|
|
48
41
|
end
|
|
49
42
|
|
|
50
43
|
# Create the field accessors.
|
|
51
44
|
def create_accessors(name, meth, options = {})
|
|
52
45
|
define_method(meth) { read_attribute(name) }
|
|
53
46
|
define_method("#{meth}=") { |value| write_attribute(name, value) }
|
|
54
|
-
define_method("#{meth}?")
|
|
55
|
-
attr = read_attribute(name)
|
|
56
|
-
(options[:type] == Boolean) ? attr == true : attr.present?
|
|
57
|
-
end
|
|
47
|
+
define_method("#{meth}?") { read_attribute(name) == true } if options[:type] == Boolean
|
|
58
48
|
end
|
|
59
49
|
|
|
50
|
+
# Set up a default value for a field.
|
|
51
|
+
def set_default(name, options = {})
|
|
52
|
+
value = options[:default]
|
|
53
|
+
defaults[name] = value if value
|
|
54
|
+
end
|
|
60
55
|
end
|
|
61
56
|
end
|
|
62
57
|
end
|
data/lib/mongoid/finders.rb
CHANGED
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
module Mongoid #:nodoc:
|
|
3
3
|
module Finders #:nodoc:
|
|
4
|
-
|
|
5
|
-
# Delegate to the criteria methods that are natural for creating a new
|
|
6
|
-
# criteria.
|
|
7
|
-
[ :all_in, :any_in, :avg, :excludes, :limit, :max, :min,
|
|
8
|
-
:not_in, :only, :order_by, :skip, :sum, :where ].each do |name|
|
|
9
|
-
define_method(name) do |*args|
|
|
10
|
-
criteria.send(name, *args)
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
4
|
# Find +Documents+ given the conditions.
|
|
15
5
|
#
|
|
16
6
|
# Options:
|
|
@@ -110,6 +100,54 @@ module Mongoid #:nodoc:
|
|
|
110
100
|
find(:last, *args)
|
|
111
101
|
end
|
|
112
102
|
|
|
103
|
+
# Convenience method for returning the max value of a field.
|
|
104
|
+
#
|
|
105
|
+
# Options:
|
|
106
|
+
#
|
|
107
|
+
# field: The field to use when calculating the max.
|
|
108
|
+
#
|
|
109
|
+
# Example:
|
|
110
|
+
#
|
|
111
|
+
# <tt>Person.max(:age)</tt>
|
|
112
|
+
#
|
|
113
|
+
# Returns: <tt>Float</tt> max value.
|
|
114
|
+
def max(field)
|
|
115
|
+
Criteria.new(self).max(field)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Will execute a +Criteria+ based on the +DynamicFinder+ that gets
|
|
119
|
+
# generated.
|
|
120
|
+
#
|
|
121
|
+
# Options:
|
|
122
|
+
#
|
|
123
|
+
# name: The finder method name
|
|
124
|
+
# args: The arguments to pass to the method.
|
|
125
|
+
#
|
|
126
|
+
# Example:
|
|
127
|
+
#
|
|
128
|
+
# <tt>Person.find_all_by_title_and_age("Sir", 30)</tt>
|
|
129
|
+
# def method_missing(name, *args)
|
|
130
|
+
# dyna = DynamicFinder.new(name, *args)
|
|
131
|
+
# finder, conditions = dyna.finder, dyna.conditions
|
|
132
|
+
# results = find(finder, :conditions => conditions)
|
|
133
|
+
# results ? results : dyna.create(self)
|
|
134
|
+
# end
|
|
135
|
+
|
|
136
|
+
# Convenience method for returning the min value of a field.
|
|
137
|
+
#
|
|
138
|
+
# Options:
|
|
139
|
+
#
|
|
140
|
+
# field: The field to use when calculating the min.
|
|
141
|
+
#
|
|
142
|
+
# Example:
|
|
143
|
+
#
|
|
144
|
+
# <tt>Person.min(:age)</tt>
|
|
145
|
+
#
|
|
146
|
+
# Returns: <tt>Float</tt> min value.
|
|
147
|
+
def min(field)
|
|
148
|
+
Criteria.new(self).min(field)
|
|
149
|
+
end
|
|
150
|
+
|
|
113
151
|
# Find all documents in paginated fashion given the supplied arguments.
|
|
114
152
|
# If no parameters are passed just default to offset 0 and limit 20.
|
|
115
153
|
#
|
|
@@ -127,6 +165,56 @@ module Mongoid #:nodoc:
|
|
|
127
165
|
Criteria.translate(self, params).paginate
|
|
128
166
|
end
|
|
129
167
|
|
|
168
|
+
# Entry point for creating a new criteria from a Document. This will
|
|
169
|
+
# instantiate a new +Criteria+ object with the supplied select criterion
|
|
170
|
+
# already added to it.
|
|
171
|
+
#
|
|
172
|
+
# Options:
|
|
173
|
+
#
|
|
174
|
+
# args: A list of field names to retrict the returned fields to.
|
|
175
|
+
#
|
|
176
|
+
# Example:
|
|
177
|
+
#
|
|
178
|
+
# <tt>Person.only(:field1, :field2, :field3)</tt>
|
|
179
|
+
#
|
|
180
|
+
# Returns: <tt>Criteria</tt>
|
|
181
|
+
def only(*args)
|
|
182
|
+
Criteria.new(self).only(*args)
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
# Convenience method for returning the sum of a specified field for all
|
|
186
|
+
# documents in the database.
|
|
187
|
+
#
|
|
188
|
+
# Options:
|
|
189
|
+
#
|
|
190
|
+
# field: The field to use when calculating the sum.
|
|
191
|
+
#
|
|
192
|
+
# Example:
|
|
193
|
+
#
|
|
194
|
+
# <tt>Person.sum(:age)</tt>
|
|
195
|
+
#
|
|
196
|
+
# Returns: <tt>Float</tt> of the sum.
|
|
197
|
+
def sum(field)
|
|
198
|
+
Criteria.new(self).sum(field)
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
# Entry point for creating a new criteria from a Document. This will
|
|
202
|
+
# instantiate a new +Criteria+ object with the supplied select criterion
|
|
203
|
+
# already added to it.
|
|
204
|
+
#
|
|
205
|
+
# Options:
|
|
206
|
+
#
|
|
207
|
+
# selector: A where criteria to initialize.
|
|
208
|
+
#
|
|
209
|
+
# Example:
|
|
210
|
+
#
|
|
211
|
+
# <tt>Person.where(:field1 => "Value")</tt>
|
|
212
|
+
#
|
|
213
|
+
# Returns: <tt>Criteria</tt>
|
|
214
|
+
def where(selector = nil)
|
|
215
|
+
Criteria.new(self).where(selector)
|
|
216
|
+
end
|
|
217
|
+
|
|
130
218
|
protected
|
|
131
219
|
# Find the first object or create/initialize it.
|
|
132
220
|
def find_or(method, attrs = {})
|
data/lib/mongoid/identity.rb
CHANGED
|
@@ -13,21 +13,15 @@ module Mongoid #:nodoc:
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
protected
|
|
16
|
-
# Return the proper id for the document.
|
|
17
|
-
def generate_id
|
|
18
|
-
id = Mongo::ObjectID.new
|
|
19
|
-
Mongoid.use_object_ids ? id : id.to_s
|
|
20
|
-
end
|
|
21
|
-
|
|
22
16
|
# Set the id for the document.
|
|
23
17
|
def identify(doc)
|
|
24
18
|
doc.id = compose(doc).join(" ").identify if doc.primary_key
|
|
25
|
-
doc.id =
|
|
19
|
+
doc.id = Mongo::ObjectID.new.to_s unless doc.id
|
|
26
20
|
end
|
|
27
21
|
|
|
28
22
|
# Set the _type field on the document.
|
|
29
23
|
def type(doc)
|
|
30
|
-
doc._type = doc.class.name
|
|
24
|
+
doc._type = doc.class.name
|
|
31
25
|
end
|
|
32
26
|
|
|
33
27
|
# Generates the composite key for a document.
|
data/lib/mongoid/named_scope.rb
CHANGED
|
@@ -8,8 +8,8 @@ module Mongoid #:nodoc:
|
|
|
8
8
|
#
|
|
9
9
|
# class Person
|
|
10
10
|
# include Mongoid::Document
|
|
11
|
-
#
|
|
12
|
-
#
|
|
11
|
+
# has_one :name
|
|
12
|
+
# has_many :addresses
|
|
13
13
|
#
|
|
14
14
|
# validates_associated :name, :addresses
|
|
15
15
|
# end
|
|
@@ -25,7 +25,12 @@ module Mongoid #:nodoc:
|
|
|
25
25
|
def validate_each(document, attribute, value)
|
|
26
26
|
values = value.is_a?(Array) ? value : [ value ]
|
|
27
27
|
return if values.collect { |doc| doc.nil? || doc.valid? }.all?
|
|
28
|
-
document.errors.add(
|
|
28
|
+
document.errors.add(
|
|
29
|
+
attribute,
|
|
30
|
+
:invalid,
|
|
31
|
+
:default => options[:message],
|
|
32
|
+
:value => value
|
|
33
|
+
)
|
|
29
34
|
end
|
|
30
35
|
end
|
|
31
36
|
end
|
|
@@ -14,8 +14,13 @@ module Mongoid #:nodoc:
|
|
|
14
14
|
# end
|
|
15
15
|
class UniquenessValidator < ActiveModel::EachValidator
|
|
16
16
|
def validate_each(document, attribute, value)
|
|
17
|
-
return if document.class.where(attribute => value
|
|
18
|
-
document.errors.add(
|
|
17
|
+
return if document.class.where(attribute => value).empty?
|
|
18
|
+
document.errors.add(
|
|
19
|
+
attribute,
|
|
20
|
+
:taken,
|
|
21
|
+
:default => options[:message],
|
|
22
|
+
:value => value
|
|
23
|
+
)
|
|
19
24
|
end
|
|
20
25
|
end
|
|
21
26
|
end
|
data/lib/mongoid/validations.rb
CHANGED
data/lib/mongoid/versioning.rb
CHANGED
|
@@ -7,7 +7,7 @@ module Mongoid #:nodoc:
|
|
|
7
7
|
extend ActiveSupport::Concern
|
|
8
8
|
included do
|
|
9
9
|
field :version, :type => Integer, :default => 1
|
|
10
|
-
|
|
10
|
+
has_many :versions, :class_name => self.name
|
|
11
11
|
before_save :revise
|
|
12
12
|
end
|
|
13
13
|
module InstanceMethods
|
data/lib/mongoid.rb
CHANGED
|
@@ -23,9 +23,10 @@ require "rubygems"
|
|
|
23
23
|
|
|
24
24
|
gem "activemodel", ">= 3.0.pre"
|
|
25
25
|
gem "will_paginate", ">= 3.0.pre"
|
|
26
|
-
gem "mongo", ">= 0.
|
|
26
|
+
gem "mongo", ">= 0.18.2"
|
|
27
27
|
|
|
28
28
|
require "delegate"
|
|
29
|
+
require "observer"
|
|
29
30
|
require "singleton"
|
|
30
31
|
require "time"
|
|
31
32
|
require "active_support/core_ext"
|
|
@@ -45,6 +46,7 @@ require "active_model/validations"
|
|
|
45
46
|
require "will_paginate/collection"
|
|
46
47
|
require "mongo"
|
|
47
48
|
require "mongoid/associations"
|
|
49
|
+
require "mongoid/associations/options"
|
|
48
50
|
require "mongoid/attributes"
|
|
49
51
|
require "mongoid/callbacks"
|
|
50
52
|
require "mongoid/collection"
|
|
@@ -53,10 +55,7 @@ require "mongoid/config"
|
|
|
53
55
|
require "mongoid/contexts"
|
|
54
56
|
require "mongoid/criteria"
|
|
55
57
|
require "mongoid/cursor"
|
|
56
|
-
require "mongoid/deprecation"
|
|
57
|
-
require "mongoid/dirty"
|
|
58
58
|
require "mongoid/extensions"
|
|
59
|
-
require "mongoid/extras"
|
|
60
59
|
require "mongoid/errors"
|
|
61
60
|
require "mongoid/factory"
|
|
62
61
|
require "mongoid/field"
|
|
@@ -64,15 +63,10 @@ require "mongoid/fields"
|
|
|
64
63
|
require "mongoid/finders"
|
|
65
64
|
require "mongoid/identity"
|
|
66
65
|
require "mongoid/indexes"
|
|
67
|
-
require "mongoid/javascript"
|
|
68
66
|
require "mongoid/matchers"
|
|
69
67
|
require "mongoid/memoization"
|
|
70
68
|
require "mongoid/named_scope"
|
|
71
|
-
require "mongoid/observable"
|
|
72
|
-
require "mongoid/paths"
|
|
73
|
-
require "mongoid/persistence"
|
|
74
69
|
require "mongoid/scope"
|
|
75
|
-
require "mongoid/state"
|
|
76
70
|
require "mongoid/timestamps"
|
|
77
71
|
require "mongoid/validations"
|
|
78
72
|
require "mongoid/versioning"
|
|
@@ -102,20 +96,10 @@ module Mongoid #:nodoc
|
|
|
102
96
|
#
|
|
103
97
|
# The Mongoid +Config+ singleton instance.
|
|
104
98
|
def configure
|
|
105
|
-
config =
|
|
99
|
+
config = Config.instance
|
|
106
100
|
block_given? ? yield(config) : config
|
|
107
101
|
end
|
|
108
102
|
|
|
109
|
-
# Easy convenience method for having an alert generated from the
|
|
110
|
-
# deprecation module.
|
|
111
|
-
#
|
|
112
|
-
# Example:
|
|
113
|
-
#
|
|
114
|
-
# <tt>Mongoid.deprecate("Method no longer used")</tt>
|
|
115
|
-
def deprecate(message)
|
|
116
|
-
Mongoid::Deprecation.instance.alert(message)
|
|
117
|
-
end
|
|
118
|
-
|
|
119
103
|
alias :config :configure
|
|
120
104
|
end
|
|
121
105
|
|
|
@@ -125,7 +109,7 @@ module Mongoid #:nodoc
|
|
|
125
109
|
# Example:
|
|
126
110
|
#
|
|
127
111
|
# <tt>Mongoid.database = Mongo::Connection.new.db("test")</tt>
|
|
128
|
-
|
|
112
|
+
Config.public_instance_methods(false).each do |name|
|
|
129
113
|
(class << self; self; end).class_eval <<-EOT
|
|
130
114
|
def #{name}(*args)
|
|
131
115
|
configure.send("#{name}", *args)
|