Class: RequestContext
- Inherits:
-
Object
- Object
- RequestContext
- Defined in:
- backend/app/lib/request_context.rb
Class Method Summary (collapse)
-
+ (Boolean) active?
-
+ (Object) dump
-
+ (Object) get(key)
-
+ (Object) in_global_repo
-
+ (Object) open(context = {})
-
+ (Object) put(key, val)
Class Method Details
+ (Boolean) active?
3 4 5 |
# File 'backend/app/lib/request_context.rb', line 3 def self.active? !Thread.current[:request_context].nil? end |
+ (Object) dump
44 45 46 |
# File 'backend/app/lib/request_context.rb', line 44 def self.dump Thread.current[:request_context].clone end |
+ (Object) get(key)
37 38 39 40 41 |
# File 'backend/app/lib/request_context.rb', line 37 def self.get(key) if Thread.current[:request_context] Thread.current[:request_context][key] end end |
+ (Object) in_global_repo
8 9 10 11 12 |
# File 'backend/app/lib/request_context.rb', line 8 def self.in_global_repo self.open(:repo_id => Repository.global_repo_id) do yield end end |
+ (Object) open(context = {})
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'backend/app/lib/request_context.rb', line 15 def self.open(context = {}) # Stash the original context original_context = Thread.current[:request_context] # Add in the bits we care about Thread.current[:request_context] ||= {} Thread.current[:request_context] = Thread.current[:request_context].merge(context) begin yield ensure # And restore the old context once done Thread.current[:request_context] = original_context end end |
+ (Object) put(key, val)
32 33 34 |
# File 'backend/app/lib/request_context.rb', line 32 def self.put(key, val) Thread.current[:request_context][key] = val end |