class Rack::Session::Abstract::SessionHash
def self.find(req)
def self.find(req) req.get_header RACK_SESSION end
def self.set(req, session)
def self.set(req, session) req.set_header RACK_SESSION, session end
def self.set_options(req, options)
def self.set_options(req, options) req.set_header RACK_SESSION_OPTIONS, options.dup end
def [](key)
def [](key) load_for_read! @data[key.to_s] end
def []=(key, value)
def []=(key, value) load_for_write! @data[key.to_s] = value end
def clear
def clear load_for_write! @data.clear end
def delete(key)
def delete(key) load_for_write! @data.delete(key.to_s) end
def destroy
def destroy clear @id = @store.send(:delete_session, @req, id, options) end
def dig(key, *keys)
def dig(key, *keys) load_for_read! @data.dig(key.to_s, *keys) end
def each(&block)
def each(&block) load_for_read! @data.each(&block) end
def empty?
def empty? load_for_read! @data.empty? end
def exists?
def exists? return @exists if instance_variable_defined?(:@exists) @data = {} @exists = @store.send(:session_exists?, @req) end
def fetch(key, default = Unspecified, &block)
def fetch(key, default = Unspecified, &block) load_for_read! if default == Unspecified @data.fetch(key.to_s, &block) else @data.fetch(key.to_s, default, &block) end end
def has_key?(key)
def has_key?(key) load_for_read! @data.has_key?(key.to_s) end
def id
def id return @id if @loaded or instance_variable_defined?(:@id) @id = @store.send(:extract_session_id, @req) end
def initialize(store, req)
def initialize(store, req) @store = store @req = req @loaded = false end
def inspect
def inspect if loaded? @data.inspect else "#<#{self.class}:0x#{self.object_id.to_s(16)} not yet loaded>" end end
def keys
def keys load_for_read! @data.keys end
def load!
def load! @id, session = @store.send(:load_session, @req) @data = stringify_keys(session) @loaded = true end
def load_for_read!
def load_for_read! load! if !loaded? && exists? end
def load_for_write!
def load_for_write! load! unless loaded? end
def loaded?
def loaded? @loaded end
def options
def options @req.session_options end
def replace(hash)
def replace(hash) load_for_write! @data.replace(stringify_keys(hash)) end
def stringify_keys(other)
def stringify_keys(other) # Use transform_keys after dropping Ruby 2.4 support hash = {} other.to_hash.each do |key, value| hash[key.to_s] = value end hash end
def to_hash
def to_hash load_for_read! @data.dup end
def update(hash)
def update(hash) load_for_write! @data.update(stringify_keys(hash)) end
def values
def values load_for_read! @data.values end