mongoid-rails2 1.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. data/MIT_LICENSE +20 -0
  2. data/README.rdoc +49 -0
  3. data/lib/mongoid/associations/belongs_to_related.rb +58 -0
  4. data/lib/mongoid/associations/embedded_in.rb +72 -0
  5. data/lib/mongoid/associations/embeds_many.rb +254 -0
  6. data/lib/mongoid/associations/embeds_one.rb +96 -0
  7. data/lib/mongoid/associations/has_many_related.rb +181 -0
  8. data/lib/mongoid/associations/has_one_related.rb +85 -0
  9. data/lib/mongoid/associations/meta_data.rb +29 -0
  10. data/lib/mongoid/associations/options.rb +57 -0
  11. data/lib/mongoid/associations/proxy.rb +24 -0
  12. data/lib/mongoid/associations.rb +300 -0
  13. data/lib/mongoid/attributes.rb +204 -0
  14. data/lib/mongoid/callbacks.rb +23 -0
  15. data/lib/mongoid/collection.rb +120 -0
  16. data/lib/mongoid/collections/cyclic_iterator.rb +34 -0
  17. data/lib/mongoid/collections/master.rb +29 -0
  18. data/lib/mongoid/collections/operations.rb +41 -0
  19. data/lib/mongoid/collections/slaves.rb +45 -0
  20. data/lib/mongoid/collections.rb +41 -0
  21. data/lib/mongoid/components.rb +27 -0
  22. data/lib/mongoid/concern.rb +31 -0
  23. data/lib/mongoid/config.rb +191 -0
  24. data/lib/mongoid/contexts/enumerable.rb +151 -0
  25. data/lib/mongoid/contexts/ids.rb +25 -0
  26. data/lib/mongoid/contexts/mongo.rb +285 -0
  27. data/lib/mongoid/contexts/paging.rb +50 -0
  28. data/lib/mongoid/contexts.rb +25 -0
  29. data/lib/mongoid/criteria.rb +249 -0
  30. data/lib/mongoid/criterion/complex.rb +21 -0
  31. data/lib/mongoid/criterion/exclusion.rb +65 -0
  32. data/lib/mongoid/criterion/inclusion.rb +110 -0
  33. data/lib/mongoid/criterion/optional.rb +136 -0
  34. data/lib/mongoid/cursor.rb +81 -0
  35. data/lib/mongoid/deprecation.rb +22 -0
  36. data/lib/mongoid/dirty.rb +253 -0
  37. data/lib/mongoid/document.rb +311 -0
  38. data/lib/mongoid/errors.rb +108 -0
  39. data/lib/mongoid/extensions/array/accessors.rb +17 -0
  40. data/lib/mongoid/extensions/array/aliasing.rb +4 -0
  41. data/lib/mongoid/extensions/array/assimilation.rb +26 -0
  42. data/lib/mongoid/extensions/array/conversions.rb +29 -0
  43. data/lib/mongoid/extensions/array/parentization.rb +13 -0
  44. data/lib/mongoid/extensions/big_decimal/conversions.rb +19 -0
  45. data/lib/mongoid/extensions/binary/conversions.rb +17 -0
  46. data/lib/mongoid/extensions/boolean/conversions.rb +22 -0
  47. data/lib/mongoid/extensions/date/conversions.rb +24 -0
  48. data/lib/mongoid/extensions/datetime/conversions.rb +12 -0
  49. data/lib/mongoid/extensions/float/conversions.rb +20 -0
  50. data/lib/mongoid/extensions/hash/accessors.rb +38 -0
  51. data/lib/mongoid/extensions/hash/assimilation.rb +39 -0
  52. data/lib/mongoid/extensions/hash/conversions.rb +45 -0
  53. data/lib/mongoid/extensions/hash/criteria_helpers.rb +21 -0
  54. data/lib/mongoid/extensions/hash/scoping.rb +12 -0
  55. data/lib/mongoid/extensions/integer/conversions.rb +20 -0
  56. data/lib/mongoid/extensions/nil/assimilation.rb +17 -0
  57. data/lib/mongoid/extensions/object/conversions.rb +33 -0
  58. data/lib/mongoid/extensions/objectid/conversions.rb +15 -0
  59. data/lib/mongoid/extensions/proc/scoping.rb +12 -0
  60. data/lib/mongoid/extensions/string/conversions.rb +15 -0
  61. data/lib/mongoid/extensions/string/inflections.rb +97 -0
  62. data/lib/mongoid/extensions/symbol/inflections.rb +36 -0
  63. data/lib/mongoid/extensions/time_conversions.rb +35 -0
  64. data/lib/mongoid/extensions.rb +101 -0
  65. data/lib/mongoid/extras.rb +61 -0
  66. data/lib/mongoid/factory.rb +20 -0
  67. data/lib/mongoid/field.rb +59 -0
  68. data/lib/mongoid/fields.rb +65 -0
  69. data/lib/mongoid/finders.rb +144 -0
  70. data/lib/mongoid/identity.rb +39 -0
  71. data/lib/mongoid/indexes.rb +30 -0
  72. data/lib/mongoid/javascript/functions.yml +37 -0
  73. data/lib/mongoid/javascript.rb +21 -0
  74. data/lib/mongoid/matchers/all.rb +11 -0
  75. data/lib/mongoid/matchers/default.rb +26 -0
  76. data/lib/mongoid/matchers/exists.rb +13 -0
  77. data/lib/mongoid/matchers/gt.rb +11 -0
  78. data/lib/mongoid/matchers/gte.rb +11 -0
  79. data/lib/mongoid/matchers/in.rb +11 -0
  80. data/lib/mongoid/matchers/lt.rb +11 -0
  81. data/lib/mongoid/matchers/lte.rb +11 -0
  82. data/lib/mongoid/matchers/ne.rb +11 -0
  83. data/lib/mongoid/matchers/nin.rb +11 -0
  84. data/lib/mongoid/matchers/size.rb +11 -0
  85. data/lib/mongoid/matchers.rb +36 -0
  86. data/lib/mongoid/memoization.rb +33 -0
  87. data/lib/mongoid/named_scope.rb +37 -0
  88. data/lib/mongoid/observable.rb +30 -0
  89. data/lib/mongoid/paths.rb +62 -0
  90. data/lib/mongoid/persistence/command.rb +39 -0
  91. data/lib/mongoid/persistence/insert.rb +50 -0
  92. data/lib/mongoid/persistence/insert_embedded.rb +38 -0
  93. data/lib/mongoid/persistence/remove.rb +39 -0
  94. data/lib/mongoid/persistence/remove_all.rb +37 -0
  95. data/lib/mongoid/persistence/remove_embedded.rb +50 -0
  96. data/lib/mongoid/persistence/update.rb +63 -0
  97. data/lib/mongoid/persistence.rb +222 -0
  98. data/lib/mongoid/scope.rb +75 -0
  99. data/lib/mongoid/state.rb +39 -0
  100. data/lib/mongoid/timestamps.rb +27 -0
  101. data/lib/mongoid/version.rb +4 -0
  102. data/lib/mongoid/versioning.rb +27 -0
  103. data/lib/mongoid.rb +122 -0
  104. metadata +298 -0
@@ -0,0 +1,222 @@
1
+ # encoding: utf-8
2
+ require "mongoid/persistence/command"
3
+ require "mongoid/persistence/insert"
4
+ require "mongoid/persistence/insert_embedded"
5
+ require "mongoid/persistence/remove"
6
+ require "mongoid/persistence/remove_all"
7
+ require "mongoid/persistence/remove_embedded"
8
+ require "mongoid/persistence/update"
9
+
10
+ module Mongoid #:nodoc:
11
+ # The persistence module is a mixin to provide database accessor methods for
12
+ # the document. These correspond to the appropriate accessors on a
13
+ # +Mongo::Collection+ and retain the same DSL.
14
+ #
15
+ # Examples:
16
+ #
17
+ # <tt>document.insert</tt>
18
+ # <tt>document.update</tt>
19
+ # <tt>document.upsert</tt>
20
+ module Persistence
21
+ extend ActiveSupport::Concern
22
+ module InstanceMethods #:nodoc:
23
+ # Remove the +Document+ from the datbase with callbacks.
24
+ #
25
+ # Example:
26
+ #
27
+ # <tt>document.destroy</tt>
28
+ #
29
+ # TODO: Will get rid of other #destroy once new persistence complete.
30
+ def destroy
31
+ run_callbacks(:before_destroy)
32
+ if _remove
33
+ self.destroyed = true
34
+ run_callbacks(:after_destroy)
35
+ end; true
36
+ end
37
+
38
+ # Insert a new +Document+ into the database. Will return the document
39
+ # itself whether or not the save was successful.
40
+ #
41
+ # Example:
42
+ #
43
+ # <tt>document.insert</tt>
44
+ def insert(validate = true)
45
+ Insert.new(self, validate).persist
46
+ end
47
+
48
+ # Remove the +Document+ from the datbase.
49
+ #
50
+ # Example:
51
+ #
52
+ # <tt>document._remove</tt>
53
+ #
54
+ # TODO: Will get rid of other #remove once observable pattern killed.
55
+ def _remove
56
+ Remove.new(self).persist
57
+ end
58
+
59
+ alias :delete :_remove
60
+
61
+ # Save the document - will perform an insert if the document is new, and
62
+ # update if not. If a validation error occurs a
63
+ # Mongoid::Errors::Validations error will get raised.
64
+ #
65
+ # Example:
66
+ #
67
+ # <tt>document.save!</tt>
68
+ #
69
+ # Returns:
70
+ #
71
+ # +true+ if validation passed, will raise error otherwise.
72
+ def save!
73
+ self.class.fail_validate!(self) unless upsert; true
74
+ end
75
+
76
+ # Update the +Document+ in the datbase.
77
+ #
78
+ # Example:
79
+ #
80
+ # <tt>document.update</tt>
81
+ def update(validate = true)
82
+ Update.new(self, validate).persist
83
+ end
84
+
85
+ # Update the +Document+ attributes in the datbase.
86
+ #
87
+ # Example:
88
+ #
89
+ # <tt>document.update_attributes(:title => "Sir")</tt>
90
+ #
91
+ # Returns:
92
+ #
93
+ # +true+ if validation passed, +false+ if not.
94
+ def update_attributes(attributes = {})
95
+ write_attributes(attributes); update
96
+ end
97
+
98
+ # Update the +Document+ attributes in the datbase.
99
+ #
100
+ # Example:
101
+ #
102
+ # <tt>document.update_attributes(:title => "Sir")</tt>
103
+ #
104
+ # Returns:
105
+ #
106
+ # +true+ if validation passed, raises an error if not
107
+ def update_attributes!(attributes = {})
108
+ write_attributes(attributes)
109
+ result = update
110
+ self.class.fail_validate!(self) unless result
111
+ result
112
+ end
113
+
114
+ # Upsert the document - will perform an insert if the document is new, and
115
+ # update if not.
116
+ #
117
+ # Example:
118
+ #
119
+ # <tt>document.upsert</tt>
120
+ #
121
+ # Returns:
122
+ #
123
+ # A +Boolean+ for updates.
124
+ def upsert(validate = true)
125
+ validate = parse_validate(validate)
126
+ if new_record?
127
+ insert(validate).errors.any? ? false : true
128
+ else
129
+ update(validate)
130
+ end
131
+ end
132
+
133
+ # Save is aliased so that users familiar with active record can have some
134
+ # semblance of a familiar API.
135
+ #
136
+ # Example:
137
+ #
138
+ # <tt>document.save</tt>
139
+ alias :save :upsert
140
+
141
+ protected
142
+ # Alternative validation params.
143
+ def parse_validate(validate)
144
+ if validate.is_a?(Hash) && validate.has_key?(:validate)
145
+ validate = validate[:validate]
146
+ end
147
+ validate
148
+ end
149
+ end
150
+
151
+ module ClassMethods #:nodoc:
152
+
153
+ # Create a new +Document+. This will instantiate a new document and
154
+ # insert it in a single call. Will always return the document
155
+ # whether save passed or not.
156
+ #
157
+ # Example:
158
+ #
159
+ # <tt>Person.create(:title => "Mr")</tt>
160
+ #
161
+ # Returns: the +Document+.
162
+ def create(attributes = {})
163
+ document = new(attributes); document.insert
164
+ end
165
+
166
+ # Create a new +Document+. This will instantiate a new document and
167
+ # insert it in a single call. Will always return the document
168
+ # whether save passed or not, and if validation fails an error will be
169
+ # raise.
170
+ #
171
+ # Example:
172
+ #
173
+ # <tt>Person.create!(:title => "Mr")</tt>
174
+ #
175
+ # Returns: the +Document+.
176
+ def create!(attributes = {})
177
+ document = new(attributes)
178
+ fail_validate!(document) if document.insert.errors.any?
179
+ document
180
+ end
181
+
182
+ # Delete all documents given the supplied conditions. If no conditions
183
+ # are passed, the entire collection will be dropped for performance
184
+ # benefits. Does not fire any callbacks.
185
+ #
186
+ # Example:
187
+ #
188
+ # <tt>Person.delete_all(:conditions => { :title => "Sir" })</tt>
189
+ # <tt>Person.delete_all</tt>
190
+ #
191
+ # Returns: true or raises an error.
192
+ def delete_all(conditions = {})
193
+ RemoveAll.new(
194
+ self,
195
+ false,
196
+ conditions[:conditions] || {}
197
+ ).persist
198
+ end
199
+
200
+ # Delete all documents given the supplied conditions. If no conditions
201
+ # are passed, the entire collection will be dropped for performance
202
+ # benefits. Fires the destroy callbacks if conditions were passed.
203
+ #
204
+ # Example:
205
+ #
206
+ # <tt>Person.destroy_all(:conditions => { :title => "Sir" })</tt>
207
+ # <tt>Person.destroy_all</tt>
208
+ #
209
+ # Returns: true or raises an error.
210
+ def destroy_all(conditions = {})
211
+ documents = all(conditions)
212
+ count = documents.count
213
+ documents.each { |doc| doc.destroy }; count
214
+ end
215
+
216
+ # Raise an error if validation failed.
217
+ def fail_validate!(document)
218
+ raise Errors::Validations.new(document.errors)
219
+ end
220
+ end
221
+ end
222
+ end
@@ -0,0 +1,75 @@
1
+ # encoding: utf-8
2
+ module Mongoid #:nodoc:
3
+ class Scope #:nodoc:
4
+
5
+ delegate :scopes, :to => :parent
6
+
7
+ attr_reader :parent, :conditions
8
+
9
+ # If the other is a scope then compare the parent and conditions, otherwise
10
+ # if its enumerable collect and compare.
11
+ def ==(other)
12
+ case other
13
+ when Scope
14
+ @parent == other.parent && @conditions == other.conditions
15
+ when Enumerable
16
+ @collection ||= entries
17
+ return (@collection == other)
18
+ else
19
+ return false
20
+ end
21
+ end
22
+
23
+ # Create the new +Scope+. If a block is passed in, this Scope will extend
24
+ # the block.
25
+ #
26
+ # Options:
27
+ #
28
+ # parent: The class the scope belongs to, or a parent +Scope+.
29
+ # conditions: A +Hash+ of conditions.
30
+ #
31
+ # Example:
32
+ #
33
+ # Mongoid::Scope.new(Person, { :title => "Sir" }) do
34
+ # def knighted?
35
+ # title == "Sir"
36
+ # end
37
+ # end
38
+ def initialize(parent, conditions, &block)
39
+ @parent, @conditions = parent, conditions
40
+ extend Module.new(&block) if block_given?
41
+ end
42
+
43
+ # Return the class for the +Scope+. This will be the parent if the parent
44
+ # is a class, otherwise will be nil.
45
+ def klass
46
+ @klass ||= @parent unless @parent.is_a?(Scope)
47
+ end
48
+
49
+ # Chaining is supported through method_missing. If a scope is already
50
+ # defined with the method name the call will be passed there, otherwise it
51
+ # will be passed to the target or parent.
52
+ def method_missing(name, *args, &block)
53
+ if scopes.include?(name)
54
+ scopes[name].call(self, *args)
55
+ elsif klass
56
+ target.send(name, *args, &block)
57
+ else
58
+ @parent.fuse(@conditions); @parent.send(name, *args, &block)
59
+ end
60
+ end
61
+
62
+ # The +Scope+ must respond like a +Criteria+ object. If this is a parent
63
+ # criteria delegate to the target, otherwise bubble up to the parent.
64
+ def respond_to?(name)
65
+ super || (klass ? target.respond_to?(name) : @parent.respond_to?(name))
66
+ end
67
+
68
+ # Returns the target criteria if it has already been set or creates a new
69
+ # criteria from the parent class.
70
+ def target
71
+ @target ||= klass.criteria.fuse(@conditions)
72
+ end
73
+ end
74
+ end
75
+
@@ -0,0 +1,39 @@
1
+ # encoding: utf-8
2
+ module Mongoid #:nodoc:
3
+ module State #:nodoc:
4
+ extend ActiveSupport::Concern
5
+ included do
6
+ attr_reader :new_record
7
+ end
8
+
9
+ module InstanceMethods
10
+ # Returns true if the +Document+ has not been persisted to the database,
11
+ # false if it has. This is determined by the variable @new_record
12
+ # and NOT if the object has an id.
13
+ def new_record?
14
+ !!@new_record
15
+ end
16
+
17
+ # Sets the new_record boolean - used after document is saved.
18
+ def new_record=(saved)
19
+ @new_record = saved
20
+ end
21
+
22
+ # Checks if the document has been saved to the database.
23
+ def persisted?
24
+ !new_record?
25
+ end
26
+
27
+ # Returns true if the +Document+ has been succesfully destroyed, and false if it hasn't.
28
+ # This is determined by the variable @destroyed and NOT by checking the database.
29
+ def destroyed?
30
+ @destroyed == true
31
+ end
32
+
33
+ # Sets the destroyed boolean - used after document is destroyed.
34
+ def destroyed=(destroyed)
35
+ @destroyed = destroyed && true
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,27 @@
1
+ # encoding: utf-8
2
+ module Mongoid
3
+ module Timestamps
4
+ extend ActiveSupport::Concern
5
+ included do
6
+ field :created_at, :type => Time
7
+ field :updated_at, :type => Time
8
+ before_save :set_created_at, :set_updated_at
9
+ end
10
+
11
+ module InstanceMethods
12
+
13
+ # Update the created_at field on the Document to the current time. This is
14
+ # only called on create.
15
+ def set_created_at
16
+ self.created_at = Time.now.utc if !created_at
17
+ end
18
+
19
+ # Update the updated_at field on the Document to the current time.
20
+ # This is only called on create and on save.
21
+ def set_updated_at
22
+ self.updated_at = Time.now.utc
23
+ end
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,4 @@
1
+ # encoding: utf-8
2
+ module Mongoid #:nodoc
3
+ VERSION = "1.9.3"
4
+ end
@@ -0,0 +1,27 @@
1
+ # encoding: utf-8
2
+ module Mongoid #:nodoc:
3
+ # Include this module to get automatic versioning of root level documents.
4
+ # This will add a version field to the +Document+ and a has_many association
5
+ # with all the versions contained in it.
6
+ module Versioning
7
+ extend ActiveSupport::Concern
8
+ included do
9
+ field :version, :type => Integer, :default => 1
10
+ embeds_many :versions, :class_name => self.name
11
+ before_save :revise
12
+ end
13
+ module InstanceMethods
14
+ # Create a new version of the +Document+. This will load the previous
15
+ # document from the database and set it as the next version before saving
16
+ # the current document. It then increments the version number.
17
+ def revise
18
+ last_version = self.class.first(:conditions => { :_id => id, :version => version })
19
+ if last_version
20
+ self.versions << last_version.clone
21
+ self.version = version + 1
22
+ @modifications["versions"] = [ nil, @attributes["versions"] ] if @modifications
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
data/lib/mongoid.rb ADDED
@@ -0,0 +1,122 @@
1
+ # encoding: utf-8
2
+ # Copyright (c) 2009 Durran Jordan
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ require "delegate"
23
+ require "singleton"
24
+ require "time"
25
+ require "validatable"
26
+ require "active_support/callbacks"
27
+ require "active_support/core_ext"
28
+ require "active_support/inflector"
29
+ require "active_support/time_with_zone"
30
+ require "will_paginate/collection"
31
+ require "mongo"
32
+ require "mongoid/concern"
33
+ require "mongoid/observable"
34
+ require "mongoid/associations"
35
+ require "mongoid/attributes"
36
+ require "mongoid/callbacks"
37
+ require "mongoid/collection"
38
+ require "mongoid/collections"
39
+ require "mongoid/config"
40
+ require "mongoid/contexts"
41
+ require "mongoid/criteria"
42
+ require "mongoid/cursor"
43
+ require "mongoid/deprecation"
44
+ require "mongoid/dirty"
45
+ require "mongoid/extensions"
46
+ require "mongoid/extras"
47
+ require "mongoid/errors"
48
+ require "mongoid/factory"
49
+ require "mongoid/field"
50
+ require "mongoid/fields"
51
+ require "mongoid/finders"
52
+ require "mongoid/identity"
53
+ require "mongoid/indexes"
54
+ require "mongoid/javascript"
55
+ require "mongoid/matchers"
56
+ require "mongoid/memoization"
57
+ require "mongoid/named_scope"
58
+ require "mongoid/paths"
59
+ require "mongoid/persistence"
60
+ require "mongoid/scope"
61
+ require "mongoid/state"
62
+ require "mongoid/timestamps"
63
+ require "mongoid/versioning"
64
+ require "mongoid/components"
65
+ require "mongoid/document"
66
+
67
+ module Mongoid #:nodoc
68
+
69
+ MONGODB_VERSION = "1.4.0"
70
+
71
+ class << self
72
+
73
+ # Sets the Mongoid configuration options. Best used by passing a block.
74
+ #
75
+ # Example:
76
+ #
77
+ # Mongoid.configure do |config|
78
+ # name = "mongoid_test"
79
+ # host = "localhost"
80
+ # config.allow_dynamic_fields = false
81
+ # config.master = Mongo::Connection.new.db(name)
82
+ # config.slaves = [
83
+ # Mongo::Connection.new(host, 27018, :slave_ok => true).db(name),
84
+ # Mongo::Connection.new(host, 27019, :slave_ok => true).db(name)
85
+ # ]
86
+ # end
87
+ #
88
+ # Returns:
89
+ #
90
+ # The Mongoid +Config+ singleton instance.
91
+ def configure
92
+ config = Mongoid::Config.instance
93
+ block_given? ? yield(config) : config
94
+ end
95
+
96
+ # Easy convenience method for having an alert generated from the
97
+ # deprecation module.
98
+ #
99
+ # Example:
100
+ #
101
+ # <tt>Mongoid.deprecate("Method no longer used")</tt>
102
+ def deprecate(message)
103
+ Mongoid::Deprecation.instance.alert(message)
104
+ end
105
+
106
+ alias :config :configure
107
+ end
108
+
109
+ # Take all the public instance methods from the Config singleton and allow
110
+ # them to be accessed through the Mongoid module directly.
111
+ #
112
+ # Example:
113
+ #
114
+ # <tt>Mongoid.database = Mongo::Connection.new.db("test")</tt>
115
+ Mongoid::Config.public_instance_methods(false).each do |name|
116
+ (class << self; self; end).class_eval <<-EOT
117
+ def #{name}(*args)
118
+ configure.send("#{name}", *args)
119
+ end
120
+ EOT
121
+ end
122
+ end