Class: Warden::Serializers::Session

Inherits:
Base
  • Object
show all
Defined in:
lib/warden/serializers/session.rb

Overview

A session serializer provided by Warden. You need to implement the serialize and deserialize methods in order to use it.

Instance Attribute Summary

Attributes inherited from Base

#env

Instance Method Summary collapse

Methods inherited from Base

#deserialize, #initialize, #key_for, #serialize

Methods included from Mixins::Common

#params, #request, #reset_session!, #response, #session

Constructor Details

This class inherits a constructor from Warden::Serializers::Base

Instance Method Details

#delete(scope, user = nil) ⇒ Object



23
24
25
# File 'lib/warden/serializers/session.rb', line 23

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

#fetch(scope) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/warden/serializers/session.rb', line 11

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

#store(user, scope) ⇒ Object



7
8
9
# File 'lib/warden/serializers/session.rb', line 7

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

#stored?(scope) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/warden/serializers/session.rb', line 19

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