Sha256: 2c84d487d9faad3695c2800e4b43908339b9991d1bc791498e4d67dc869d57f9

Contents?: true

Size: 592 Bytes

Versions: 3

Compression:

Stored size: 592 Bytes

Contents

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.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
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
request_store-1.0.8 lib/request_store.rb
request_store-1.0.7 lib/request_store.rb
request_store-1.0.6 lib/request_store.rb