class ScopedStorage::ThreadGlobalStorage
Attributes
data[RW]
Public Class Methods
for(scope_name="default")
click to toggle source
# File lib/scoped_storage/thread_global_storage.rb, line 17 def self.for(scope_name="default") mutex.synchronize { @storage ||= {} @storage[scope_name] ||= new } end
mutex()
click to toggle source
# File lib/scoped_storage/thread_global_storage.rb, line 13 def self.mutex @mutex end
new()
click to toggle source
# File lib/scoped_storage/thread_global_storage.rb, line 24 def initialize self.data||={} end
Public Instance Methods
[](key)
click to toggle source
# File lib/scoped_storage/thread_global_storage.rb, line 34 def [](key) self.data[key] end
[]=(key, value)
click to toggle source
# File lib/scoped_storage/thread_global_storage.rb, line 28 def []=(key, value) mutex.synchronize { self.data[key]=value } end
clear!()
click to toggle source
# File lib/scoped_storage/thread_global_storage.rb, line 38 def clear! mutex.synchronize { self.data.clear } end
fetch(*args, &block)
click to toggle source
# File lib/scoped_storage/thread_global_storage.rb, line 44 def fetch(*args, &block) self.data.fetch(*args, &block) end
mutex()
click to toggle source
# File lib/scoped_storage/thread_global_storage.rb, line 48 def mutex self.class.mutex end