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
-
#begin(name) ⇒ true
Begin entry into a named thread local stack.
-
#begin_validate(document) ⇒ Object
Begin validating a document on the current thread.
-
#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.
-
#executing?(name) ⇒ true
Are in the middle of executing the named stack.
-
#exit(name) ⇒ true
Exit from a named thread local stack.
-
#exit_validate(document) ⇒ Object
Exit validating a document on the current thread.
-
#identity_map ⇒ IdentityMap
Get the identity map off the current thread.
-
#insert(name) ⇒ Object
Get the insert consumer from the current thread.
-
#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.
-
#selection ⇒ Hash
Get the field selection options from the current thread.
-
#selection=(value) ⇒ Hash
Set the field selection on the current thread.
-
#set_insert(name, consumer) ⇒ Object
Set the insert consumer on the current thread.
-
#set_update_consumer(klass, consumer) ⇒ Object
Set the update consumer on the current thread.
-
#stack(name) ⇒ Array
Get the named stack.
-
#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
#begin(name) ⇒ true
Begin entry into a named thread local stack.
21 22 23 |
# File 'lib/mongoid/threaded.rb', line 21 def begin(name) stack(name).push(true) end |
#begin_validate(document) ⇒ Object
Begin validating a document on the current thread.
75 76 77 |
# File 'lib/mongoid/threaded.rb', line 75 def begin_validate(document) validations_for(document.class).push(document.id) end |
#clear_options! ⇒ Object
Clear out all options set on a one-time basis.
97 98 99 100 |
# File 'lib/mongoid/threaded.rb', line 97 def self.timeless = false end |
#clear_safety_options! ⇒ nil
Clear out all the safety options set using the safely proxy.
87 88 89 |
# File 'lib/mongoid/threaded.rb', line 87 def Thread.current[:"[mongoid]:safety-options"] = nil end |
#executing?(name) ⇒ true
Are in the middle of executing the named stack
35 36 37 |
# File 'lib/mongoid/threaded.rb', line 35 def executing?(name) !stack(name).empty? end |
#exit(name) ⇒ true
Exit from a named thread local stack.
49 50 51 |
# File 'lib/mongoid/threaded.rb', line 49 def exit(name) stack(name).pop end |
#exit_validate(document) ⇒ Object
Exit validating a document on the current thread.
110 111 112 |
# File 'lib/mongoid/threaded.rb', line 110 def exit_validate(document) validations_for(document.class).delete_one(document.id) end |
#identity_map ⇒ IdentityMap
Get the identity map off the current thread.
122 123 124 |
# File 'lib/mongoid/threaded.rb', line 122 def identity_map Thread.current[:"[mongoid]:identity-map"] ||= IdentityMap.new end |
#insert(name) ⇒ Object
Get the insert consumer from the current thread.
134 135 136 |
# File 'lib/mongoid/threaded.rb', line 134 def insert(name) Thread.current[:"[mongoid][#{name}]:insert-consumer"] end |
#safety_options ⇒ Hash
Get the safety options for the current thread.
160 161 162 |
# File 'lib/mongoid/threaded.rb', line 160 def Thread.current[:"[mongoid]:safety-options"] end |
#safety_options=(options) ⇒ Hash
Set the safety options on the current thread.
174 175 176 |
# File 'lib/mongoid/threaded.rb', line 174 def () Thread.current[:"[mongoid]:safety-options"] = end |
#scope_stack ⇒ Hash
Get the mongoid scope stack for chained criteria.
212 213 214 |
# File 'lib/mongoid/threaded.rb', line 212 def scope_stack Thread.current[:"[mongoid]:scope-stack"] ||= {} end |
#selection ⇒ Hash
Get the field selection options from the current thread.
186 187 188 |
# File 'lib/mongoid/threaded.rb', line 186 def selection Thread.current[:"[mongoid]:selection"] end |
#selection=(value) ⇒ Hash
Set the field selection on the current thread.
200 201 202 |
# File 'lib/mongoid/threaded.rb', line 200 def selection=(value) Thread.current[:"[mongoid]:selection"] = value end |
#set_insert(name, consumer) ⇒ Object
Set the insert consumer on the current thread.
148 149 150 |
# File 'lib/mongoid/threaded.rb', line 148 def set_insert(name, consumer) Thread.current[:"[mongoid][#{name}]:insert-consumer"] = consumer end |
#set_update_consumer(klass, consumer) ⇒ Object
Set the update consumer on the current thread.
262 263 264 |
# File 'lib/mongoid/threaded.rb', line 262 def set_update_consumer(klass, consumer) Thread.current[:"[mongoid][#{klass}]:update-consumer"] = consumer end |
#stack(name) ⇒ Array
Get the named stack.
63 64 65 |
# File 'lib/mongoid/threaded.rb', line 63 def stack(name) Thread.current[:"[mongoid]:#{name}-stack"] ||= [] end |
#timeless ⇒ true, false
Get the value of the one-off timeless call.
224 225 226 |
# File 'lib/mongoid/threaded.rb', line 224 def timeless !!Thread.current[:"[mongoid]:timeless"] end |
#timeless=(value) ⇒ Object
Set the value of the one-off timeless call.
236 237 238 |
# File 'lib/mongoid/threaded.rb', line 236 def timeless=(value) Thread.current[:"[mongoid]:timeless"] = value end |
#timestamping? ⇒ true, false
Is the current thread setting timestamps?
274 275 276 |
# File 'lib/mongoid/threaded.rb', line 274 def !timeless end |
#update_consumer(klass) ⇒ Object
Get the update consumer from the current thread.
248 249 250 |
# File 'lib/mongoid/threaded.rb', line 248 def update_consumer(klass) Thread.current[:"[mongoid][#{klass}]:update-consumer"] end |
#validated?(document) ⇒ true, false
Is the document validated on the current thread?
288 289 290 |
# File 'lib/mongoid/threaded.rb', line 288 def validated?(document) validations_for(document.class).include?(document.id) end |
#validations ⇒ Hash
Get all validations on the current thread.
300 301 302 |
# File 'lib/mongoid/threaded.rb', line 300 def validations Thread.current[:"[mongoid]:validations"] ||= {} end |
#validations_for(klass) ⇒ Array
Get all validations on the current thread for the class.
314 315 316 |
# File 'lib/mongoid/threaded.rb', line 314 def validations_for(klass) validations[klass] ||= [] end |