D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
td-agent
/
embedded
/
lib
/
ruby
/
gems
/
2.1.0
/
gems
/
request_store-1.3.2
/
lib
/
Filename :
request_store.rb
back
Copy
require "request_store/version" require "request_store/middleware" require "request_store/railtie" if defined?(Rails::Railtie) module RequestStore def self.store Thread.current[:request_store] ||= {} end def self.clear! Thread.current[:request_store] = {} end def self.begin! Thread.current[:request_store_active] = true end def self.end! Thread.current[:request_store_active] = false end def self.active? Thread.current[:request_store_active] || false end def self.read(key) store[key] end def self.[](key) store[key] end def self.write(key, value) store[key] = value end def self.[]=(key, value) store[key] = value end def self.exist?(key) store.key?(key) end def self.fetch(key, &block) store[key] = yield unless exist?(key) store[key] end def self.delete(key, &block) store.delete(key, &block) end end