module RequestStore
A middleware that ensures the RequestStore
stays around until the last part of the body is rendered. This is useful when using streaming.
Uses Rack::BodyProxy, adapted from Rack::Lock's usage of the same pattern.
Constants
- VERSION
Public Class Methods
[](key)
click to toggle source
# File lib/request_store.rb, line 44 def self.[](key) store[key] end
[]=(key, value)
click to toggle source
# File lib/request_store.rb, line 52 def self.[]=(key, value) store[key] = value end
active?()
click to toggle source
# File lib/request_store.rb, line 36 def self.active? scope[:request_store_active] || false end
begin!()
click to toggle source
# File lib/request_store.rb, line 28 def self.begin! scope[:request_store_active] = true end
clear!()
click to toggle source
# File lib/request_store.rb, line 24 def self.clear! scope[:request_store] = {} end
delete(key, &block)
click to toggle source
# File lib/request_store.rb, line 65 def self.delete(key, &block) store.delete(key, &block) end
end!()
click to toggle source
# File lib/request_store.rb, line 32 def self.end! scope[:request_store_active] = false end
exist?(key)
click to toggle source
# File lib/request_store.rb, line 56 def self.exist?(key) store.key?(key) end
fetch(key) { || ... }
click to toggle source
# File lib/request_store.rb, line 60 def self.fetch(key) store[key] = yield unless exist?(key) store[key] end
read(key)
click to toggle source
# File lib/request_store.rb, line 40 def self.read(key) store[key] end
scope()
click to toggle source
# File lib/request_store.rb, line 7 def self.scope Fiber end
store()
click to toggle source
# File lib/request_store.rb, line 16 def self.store scope[:request_store] ||= {} end
store=(store)
click to toggle source
# File lib/request_store.rb, line 20 def self.store=(store) scope[:request_store] = store end
write(key, value)
click to toggle source
# File lib/request_store.rb, line 48 def self.write(key, value) store[key] = value end