Class: Ixtlan::UserManagement::SessionManager
- Inherits:
-
Object
- Object
- Ixtlan::UserManagement::SessionManager
- Defined in:
- lib/ixtlan/user_management/session_manager.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
Returns the value of attribute block.
-
#idle_session_timeout ⇒ Object
Returns the value of attribute idle_session_timeout.
Instance Method Summary collapse
- #create(user) ⇒ Object
- #from_session(data) ⇒ Object
-
#initialize(&block) ⇒ SessionManager
constructor
A new instance of SessionManager.
- #serializer(user) ⇒ Object
- #to_session(user) ⇒ Object
Constructor Details
#initialize(&block) ⇒ SessionManager
Returns a new instance of SessionManager.
31 32 33 |
# File 'lib/ixtlan/user_management/session_manager.rb', line 31 def initialize( &block ) @block = block || lambda { [] } end |
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block.
29 30 31 |
# File 'lib/ixtlan/user_management/session_manager.rb', line 29 def block @block end |
#idle_session_timeout ⇒ Object
Returns the value of attribute idle_session_timeout.
29 30 31 |
# File 'lib/ixtlan/user_management/session_manager.rb', line 29 def idle_session_timeout @idle_session_timeout end |
Instance Method Details
#create(user) ⇒ Object
63 64 65 66 67 |
# File 'lib/ixtlan/user_management/session_manager.rb', line 63 def create( user ) Session.new( 'user' => user, 'permissions' => block.call( user.groups ), 'idle_session_timeout' => idle_session_timeout ) end |
#from_session(data) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/ixtlan/user_management/session_manager.rb', line 44 def from_session( data ) if data data = data.dup groups = (data.delete( 'groups' ) || []).collect do |g| Group.new( g ) end user = User.first( :login => data[ 'login' ] ) user.groups = groups if user user end end |
#serializer(user) ⇒ Object
35 36 37 |
# File 'lib/ixtlan/user_management/session_manager.rb', line 35 def serializer( user ) UserSerializer.new( user ) end |
#to_session(user) ⇒ Object
39 40 41 |
# File 'lib/ixtlan/user_management/session_manager.rb', line 39 def to_session( user ) serializer( user ).use( :session ).to_hash end |