Sha256: add66175b612c9f16df3cc1d97271ac0ab0899d17ab26cbd4fa440a70e8d0c51
Contents?: true
Size: 1.04 KB
Versions: 7
Compression:
Stored size: 1.04 KB
Contents
require "mongo_session_store/mongo_store_base" module ActionDispatch module Session class MongoidStore < MongoStoreBase class Session include Mongoid::Document include Mongoid::Timestamps attr_writer :data store_in :collection => MongoSessionStore.collection_name field :_data, :type => BSON::Binary, :default => -> { pack({}) } def self.pack(data) BSON::Binary.new(Marshal.dump(data), :generic) end def data @data ||= unpack(_data) end def reload @data = nil super end private before_save do self._data = pack(data) end def pack(data) self.class.pack(data) end def unpack(packed) return unless packed if packed.respond_to? :data Marshal.load(packed.data) else Marshal.load(packed.to_s) end end end end end end MongoidStore = ActionDispatch::Session::MongoidStore
Version data entries
7 entries across 7 versions & 2 rubygems