Sha256: c055a68a8e793e4f750551ceead105b4086c798584626b54fed054cade3a689f

Contents?: true

Size: 775 Bytes

Versions: 31

Compression:

Stored size: 775 Bytes

Contents

# encoding: utf-8
module Warden
  class SessionSerializer
    attr_reader :env
    include ::Warden::Mixins::Common

    def initialize(env)
      @env = env
    end

    def key_for(scope)
      "warden.user.#{scope}.key"
    end

    def serialize(user)
      user
    end

    def deserialize(key)
      key
    end

    def store(user, scope)
      return unless user
      session[key_for(scope)] = serialize(user)
    end

    def fetch(scope)
      key = session[key_for(scope)]
      return nil unless key
      user = deserialize(key)
      delete(scope) unless user
      user
    end

    def stored?(scope)
      !!session[key_for(scope)]
    end

    def delete(scope, user=nil)
      session.delete(key_for(scope))
    end
  end # SessionSerializer
end # Warden

Version data entries

31 entries across 31 versions & 3 rubygems

Version Path
devise_sociable-0.1.0 vendor/bundle/gems/warden-1.0.6/lib/warden/session_serializer.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/warden-1.1.1/lib/warden/session_serializer.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/warden-1.1.1/lib/warden/session_serializer.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/warden-1.1.1/lib/warden/session_serializer.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/warden-1.1.1/lib/warden/session_serializer.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/warden-1.1.1/lib/warden/session_serializer.rb
warden-1.1.1 lib/warden/session_serializer.rb
warden-1.1.0 lib/warden/session_serializer.rb
warden-1.0.6 lib/warden/session_serializer.rb
warden-1.0.5 lib/warden/session_serializer.rb
warden-1.0.4 lib/warden/session_serializer.rb
warden-1.0.3 lib/warden/session_serializer.rb
warden-1.0.2 lib/warden/session_serializer.rb
warden-1.0.1 lib/warden/session_serializer.rb
warden-1.0.0 lib/warden/session_serializer.rb
warden-0.10.7 lib/warden/session_serializer.rb
warden-0.10.6 lib/warden/session_serializer.rb
warden-0.10.5 lib/warden/session_serializer.rb
warden-0.10.4 lib/warden/session_serializer.rb
warden-0.10.3 lib/warden/session_serializer.rb