File tree Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ toc_landing_pages = [
13
13
" /quick-start-rails" ,
14
14
" /quick-start-sinatra" ,
15
15
" /interact-data/specify-query" ,
16
- " /issues-and-help"
16
+ " /issues-and-help" ,
17
17
]
18
18
19
19
[constants ]
@@ -31,5 +31,6 @@ server-manual = "Server manual"
31
31
api = " https://www.mongodb.com/docs/mongoid/current/api"
32
32
ruby-api = " https://www.mongodb.com/docs/ruby-driver/current/api"
33
33
active-record-docs = " https://guides.rubyonrails.org"
34
+ ruby-lang-api = " https://docs.ruby-lang.org/en/3.4"
34
35
shared-library = " Automatic Encryption Shared Library"
35
36
mdb-server = " MongoDB Server"
Original file line number Diff line number Diff line change @@ -162,6 +162,25 @@ instance:
162
162
:emphasize-lines: 6, 10-15
163
163
:dedent:
164
164
165
+ .. _mongoid-callbacks-thread-local-vars:
166
+
167
+ Thread-Local Variables
168
+ ~~~~~~~~~~~~~~~~~~~~~~
169
+
170
+ If you have embedded child documents in an association that has
171
+ ``cascade_callbacks: true`` configured, then the embedded child
172
+ callbacks are executed within a {+language+} `Fiber
173
+ <{+ruby-lang-api+}/Fiber.html>`__. This means that if you are using the
174
+ ``Thread#[]`` and ``Thread#[]=`` methods to get and set fiber-local
175
+ variables, those callbacks are not reading or setting the values you expect.
176
+
177
+ We recommend that you use the ``Thread#thread_variable_get`` and
178
+ ``Thread#thread_variable_set`` methods to get and set true
179
+ thread-local variables. For convenience, {+odm+} v9.0.3 introduces
180
+ the `Mongoid::Threaded.get <{+api+}/Mongoid/Threaded.html#get-instance_method>`__
181
+ and `Mongoid::Threaded.set <{+api+}/Mongoid/Threaded.html#set-instance_method>`__
182
+ methods to implement this functionality.
183
+
165
184
Additional Information
166
185
----------------------
167
186
Original file line number Diff line number Diff line change @@ -178,6 +178,17 @@ Removal of Deprecated Functionality
178
178
- The deprecated class ``{+odm+}::Errors::InvalidStorageParent`` has
179
179
been removed.
180
180
181
+ Get and Set Thread-Local Variables
182
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
183
+
184
+ .. versionadded:: 9.0.3
185
+
186
+ You can use the `Mongoid::Threaded.get <{+api+}/Mongoid/Threaded.html#get-instance_method>`__
187
+ and `Mongoid::Threaded.set <{+api+}/Mongoid/Threaded.html#set-instance_method>`__
188
+ methods to query and modify thread-local variables. To learn when to use
189
+ these methods, see the :ref:`mongoid-callbacks-thread-local-vars`
190
+ section of the Callbacks guide.
191
+
181
192
Index Verification Configuration
182
193
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
183
194
You can’t perform that action at this time.
0 commit comments