Sha256: 2b757c2404db3cd8f0d27a306f243655ad67f106b765dc673f37e9663611ea0a
Contents?: true
Size: 1.74 KB
Versions: 1
Compression:
Stored size: 1.74 KB
Contents
module RocketIO class Controller # setup sessions. # there are 2 setups out of the box: # - cookies # - memcache # you can also use your own setup # # @note to disable sessions for some controller set sessions to nil or false # # @example keep sessions in cookies # sessions :cookies # # @example keep sessions in cookies using custom options # sessions :cookies, secret: 'someSecret', domain: 'some.domain' # # @example keep sessions in memcache # sessions :memcache # # @example use a custom setup, i.e. github.com/migrs/rack-session-mongo # $ gem install rack-session-mongo # # require 'rack/session/mongo' # # class Pages < RocketIO::Controller # sessions Rack::Session::Mongo # end # # @example disable sessions for current controller # sessions nil # or false # # @param pool [Symbol, Class] # @param opts [Hash] # def self.sessions pool = (noargs = true; nil), opts = {} @__sessions__ = if pool.nil? || pool == false nil else if pool == :cookies && opts[:secret].nil? opts[:secret] = ::Digest::MD5.hexdigest([Time.now.to_f, rand]*'') end pool = case pool when :cookies ::Rack::Session::Cookie when :memcache ::Rack::Session::Memcache else pool end [pool, opts] end define_sessions_methods end def self.define_sessions_methods source = self return unless source.instance_variables.include?(:@__sessions__) sessions = source.instance_variable_get(:@__sessions__) private_api << define_method(:sessions) {sessions} end def sessions; end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rocketio-0.1.0 | lib/rocketio/controller/sessions.rb |