Module: Mongoid::Threaded
- Extended by:
- Threaded
- Included in:
- Threaded
- Defined in:
- lib/mongoid/threaded.rb,
lib/mongoid/threaded/lifecycle.rb
Overview
:nodoc:
Defined Under Namespace
Modules: Lifecycle
Instance Method Summary collapse
-
#assign_stack ⇒ Array
Get the assign stack for the current thread.
-
#assigning? ⇒ true, false
Is the current thread in assigning mode?.
-
#begin_assign ⇒ true
Begins a assigning block.
-
#begin_bind ⇒ true
Begins a binding block.
-
#begin_build ⇒ true
Begins a building block.
-
#begin_create ⇒ true
Begins a creating block.
-
#begin_load ⇒ true
Begins a loading block.
-
#begin_load_revision ⇒ true
Begins a loading revision block.
-
#begin_validate(document) ⇒ Object
Begin validating a document on the current thread.
-
#bind_stack ⇒ Array
Get the bind stack for the current thread.
-
#binding? ⇒ true, false
Is the current thread in binding mode?.
-
#build_stack ⇒ Array
Get the build stack for the current thread.
-
#building? ⇒ true, false
Is the current thread in building mode?.
-
#clear_options! ⇒ Object
Clear out all options set on a one-time basis.
-
#clear_safety_options! ⇒ nil
Clear out all the safety options set using the safely proxy.
-
#create_stack ⇒ Array
Get the create stack for the current thread.
-
#creating? ⇒ true, false
Is the current thread in creating mode?.
-
#exit_assign ⇒ true
Exit the assigning block.
-
#exit_bind ⇒ true
Exit the binding block.
-
#exit_build ⇒ true
Exit the building block.
-
#exit_create ⇒ true
Exit the creating block.
-
#exit_load ⇒ true
Exit the loading block.
-
#exit_load_revision ⇒ true
Exit the revision loading block.
-
#exit_validate(document) ⇒ Object
Exit validating a document on the current thread.
-
#identity_map ⇒ IdentityMap
Get the identity map off the current thread.
-
#insert ⇒ Object
Get the insert consumer from the current thread.
-
#insert=(consumer) ⇒ Object
Set the insert consumer on the current thread.
-
#load_revision_stack ⇒ Array
Get the revision load stack for the current thread.
-
#load_stack ⇒ Array
Get the load stack for the current thread.
-
#loading? ⇒ true, false
Is the current thread in loading mode?.
-
#loading_revision? ⇒ true, false
Is the current thread in revision load mode?.
-
#safety_options ⇒ Hash
Get the safety options for the current thread.
-
#safety_options=(options) ⇒ Hash
Set the safety options on the current thread.
-
#scope_stack ⇒ Hash
Get the mongoid scope stack for chained criteria.
-
#set_update_consumer(klass, consumer) ⇒ Object
Set the update consumer on the current thread.
-
#timeless ⇒ true, false
Get the value of the one-off timeless call.
-
#timeless=(value) ⇒ Object
Set the value of the one-off timeless call.
-
#timestamping? ⇒ true, false
Is the current thread setting timestamps?.
-
#update_consumer(klass) ⇒ Object
Get the update consumer from the current thread.
-
#validated?(document) ⇒ true, false
Is the document validated on the current thread?.
-
#validations ⇒ Hash
Get all validations on the current thread.
-
#validations_for(klass) ⇒ Array
Get all validations on the current thread for the class.
Instance Method Details
#assign_stack ⇒ Array
Get the assign stack for the current thread. Is simply an array of calls to Mongoid’s assigning method.
176 177 178 |
# File 'lib/mongoid/threaded.rb', line 176 def assign_stack Thread.current[:"[mongoid]:assign-stack"] ||= [] end |
#assigning? ⇒ true, false
Is the current thread in assigning mode?
103 104 105 |
# File 'lib/mongoid/threaded.rb', line 103 def assigning? !assign_stack.empty? end |
#begin_assign ⇒ true
Begins a assigning block.
19 20 21 |
# File 'lib/mongoid/threaded.rb', line 19 def begin_assign assign_stack.push(true) end |
#begin_bind ⇒ true
Begins a binding block.
31 32 33 |
# File 'lib/mongoid/threaded.rb', line 31 def begin_bind bind_stack.push(true) end |
#begin_build ⇒ true
Begins a building block.
43 44 45 |
# File 'lib/mongoid/threaded.rb', line 43 def begin_build build_stack.push(true) end |
#begin_create ⇒ true
Begins a creating block.
55 56 57 |
# File 'lib/mongoid/threaded.rb', line 55 def begin_create create_stack.push(true) end |
#begin_load ⇒ true
Begins a loading block.
67 68 69 |
# File 'lib/mongoid/threaded.rb', line 67 def begin_load load_stack.push(true) end |
#begin_load_revision ⇒ true
Begins a loading revision block.
79 80 81 |
# File 'lib/mongoid/threaded.rb', line 79 def begin_load_revision load_revision_stack.push(true) end |
#begin_validate(document) ⇒ Object
Begin validating a document on the current thread.
91 92 93 |
# File 'lib/mongoid/threaded.rb', line 91 def begin_validate(document) validations_for(document.class).push(document.id) end |
#bind_stack ⇒ Array
Get the bind stack for the current thread. Is simply an array of calls to Mongoid’s binding method.
189 190 191 |
# File 'lib/mongoid/threaded.rb', line 189 def bind_stack Thread.current[:"[mongoid]:bind-stack"] ||= [] end |
#binding? ⇒ true, false
Is the current thread in binding mode?
115 116 117 |
# File 'lib/mongoid/threaded.rb', line 115 def binding? !bind_stack.empty? end |
#build_stack ⇒ Array
Get the build stack for the current thread. Is simply an array of calls to Mongoid’s building method.
202 203 204 |
# File 'lib/mongoid/threaded.rb', line 202 def build_stack Thread.current[:"[mongoid]:build-stack"] ||= [] end |
#building? ⇒ true, false
Is the current thread in building mode?
127 128 129 |
# File 'lib/mongoid/threaded.rb', line 127 def building? !build_stack.empty? end |
#clear_options! ⇒ Object
Clear out all options set on a one-time basis.
263 264 265 266 |
# File 'lib/mongoid/threaded.rb', line 263 def self.timeless = false end |
#clear_safety_options! ⇒ nil
Clear out all the safety options set using the safely proxy.
253 254 255 |
# File 'lib/mongoid/threaded.rb', line 253 def Thread.current[:"[mongoid]:safety-options"] = nil end |
#create_stack ⇒ Array
Get the create stack for the current thread. Is simply an array of calls to Mongoid’s creating method.
215 216 217 |
# File 'lib/mongoid/threaded.rb', line 215 def create_stack Thread.current[:"[mongoid]:create-stack"] ||= [] end |
#creating? ⇒ true, false
Is the current thread in creating mode?
139 140 141 |
# File 'lib/mongoid/threaded.rb', line 139 def creating? !create_stack.empty? end |
#exit_assign ⇒ true
Exit the assigning block.
276 277 278 |
# File 'lib/mongoid/threaded.rb', line 276 def exit_assign assign_stack.pop end |
#exit_bind ⇒ true
Exit the binding block.
288 289 290 |
# File 'lib/mongoid/threaded.rb', line 288 def exit_bind bind_stack.pop end |
#exit_build ⇒ true
Exit the building block.
300 301 302 |
# File 'lib/mongoid/threaded.rb', line 300 def exit_build build_stack.pop end |
#exit_create ⇒ true
Exit the creating block.
312 313 314 |
# File 'lib/mongoid/threaded.rb', line 312 def exit_create create_stack.pop end |
#exit_load ⇒ true
Exit the loading block.
324 325 326 |
# File 'lib/mongoid/threaded.rb', line 324 def exit_load load_stack.pop end |
#exit_load_revision ⇒ true
Exit the revision loading block.
336 337 338 |
# File 'lib/mongoid/threaded.rb', line 336 def exit_load_revision load_revision_stack.pop end |
#exit_validate(document) ⇒ Object
Exit validating a document on the current thread.
348 349 350 |
# File 'lib/mongoid/threaded.rb', line 348 def exit_validate(document) validations_for(document.class).delete_one(document.id) end |
#identity_map ⇒ IdentityMap
Get the identity map off the current thread.
360 361 362 |
# File 'lib/mongoid/threaded.rb', line 360 def identity_map Thread.current[:"[mongoid]:identity-map"] ||= IdentityMap.new end |
#insert ⇒ Object
Get the insert consumer from the current thread.
372 373 374 |
# File 'lib/mongoid/threaded.rb', line 372 def insert Thread.current[:"[mongoid]:insert-consumer"] end |
#insert=(consumer) ⇒ Object
Set the insert consumer on the current thread.
386 387 388 |
# File 'lib/mongoid/threaded.rb', line 386 def insert=(consumer) Thread.current[:"[mongoid]:insert-consumer"] = consumer end |
#load_revision_stack ⇒ Array
Get the revision load stack for the current thread. Is simply an array of calls to Mongoid’s loading_revision method.
241 242 243 |
# File 'lib/mongoid/threaded.rb', line 241 def load_revision_stack Thread.current[:"[mongoid]:load-revision-stack"] ||= [] end |
#load_stack ⇒ Array
Get the load stack for the current thread. Is simply an array of calls to Mongoid’s loading method.
228 229 230 |
# File 'lib/mongoid/threaded.rb', line 228 def load_stack Thread.current[:"[mongoid]:load-stack"] ||= [] end |
#loading? ⇒ true, false
Is the current thread in loading mode?
151 152 153 |
# File 'lib/mongoid/threaded.rb', line 151 def loading? !load_stack.empty? end |
#loading_revision? ⇒ true, false
Is the current thread in revision load mode?
163 164 165 |
# File 'lib/mongoid/threaded.rb', line 163 def loading_revision? !load_revision_stack.empty? end |
#safety_options ⇒ Hash
Get the safety options for the current thread.
398 399 400 |
# File 'lib/mongoid/threaded.rb', line 398 def Thread.current[:"[mongoid]:safety-options"] end |
#safety_options=(options) ⇒ Hash
Set the safety options on the current thread.
412 413 414 |
# File 'lib/mongoid/threaded.rb', line 412 def () Thread.current[:"[mongoid]:safety-options"] = end |
#scope_stack ⇒ Hash
Get the mongoid scope stack for chained criteria.
424 425 426 |
# File 'lib/mongoid/threaded.rb', line 424 def scope_stack Thread.current[:"[mongoid]:scope-stack"] ||= {} end |
#set_update_consumer(klass, consumer) ⇒ Object
Set the update consumer on the current thread.
474 475 476 |
# File 'lib/mongoid/threaded.rb', line 474 def set_update_consumer(klass, consumer) Thread.current[:"[mongoid][#{klass}]:update-consumer"] = consumer end |
#timeless ⇒ true, false
Get the value of the one-off timeless call.
436 437 438 |
# File 'lib/mongoid/threaded.rb', line 436 def timeless !!Thread.current[:"[mongoid]:timeless"] end |
#timeless=(value) ⇒ Object
Set the value of the one-off timeless call.
448 449 450 |
# File 'lib/mongoid/threaded.rb', line 448 def timeless=(value) Thread.current[:"[mongoid]:timeless"] = value end |
#timestamping? ⇒ true, false
Is the current thread setting timestamps?
486 487 488 |
# File 'lib/mongoid/threaded.rb', line 486 def !timeless end |
#update_consumer(klass) ⇒ Object
Get the update consumer from the current thread.
460 461 462 |
# File 'lib/mongoid/threaded.rb', line 460 def update_consumer(klass) Thread.current[:"[mongoid][#{klass}]:update-consumer"] end |
#validated?(document) ⇒ true, false
Is the document validated on the current thread?
500 501 502 |
# File 'lib/mongoid/threaded.rb', line 500 def validated?(document) validations_for(document.class).include?(document.id) end |
#validations ⇒ Hash
Get all validations on the current thread.
512 513 514 |
# File 'lib/mongoid/threaded.rb', line 512 def validations Thread.current[:"[mongoid]:validations"] ||= {} end |
#validations_for(klass) ⇒ Array
Get all validations on the current thread for the class.
526 527 528 |
# File 'lib/mongoid/threaded.rb', line 526 def validations_for(klass) validations[klass] ||= [] end |