Module: Merb::SessionMixin

Defined in:
lib/merb-core/dispatch/session.rb

Overview

This is mixed into Merb::Controller on framework boot.

Defined Under Namespace

Modules: RequestMixin Classes: NoSessionContainer, SessionOverflow

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



53
54
55
56
57
# File 'lib/merb-core/dispatch/session.rb', line 53

def self.included(base)
  # Register a callback to finalize sessions - needs to run before the cookie
  # callback extracts Set-Cookie headers from request.cookies.
  base._after_dispatch_callbacks.unshift lambda { |c| c.request.finalize_session }
end

.needs_new_cookie!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Marks this session as needing a new cookie.



88
89
90
# File 'lib/merb-core/dispatch/session.rb', line 88

def needs_new_cookie!
  @_new_cookie = true
end

.needs_new_cookie?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Does session need new cookie?

Returns

Boolean

true if a new cookie is needed, false otherwise.

Returns:

  • (Boolean)


98
99
100
# File 'lib/merb-core/dispatch/session.rb', line 98

def needs_new_cookie?
  @_new_cookie
end

.rand_uuidObject

Returns

String

A random 32 character string for use as a unique session ID.



72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/merb-core/dispatch/session.rb', line 72

def rand_uuid
  values = [
    rand(0x0010000),
    rand(0x0010000),
    rand(0x0010000),
    rand(0x0010000),
    rand(0x0010000),
    rand(0x1000000),
    rand(0x1000000),
  ]
  "%04x%04x%04x%04x%04x%06x%06x" % values
end

Instance Method Details

#session(session_store = nil) ⇒ Object

Parameters

session_store<String>

The type of session store to access.

Returns

SessionContainer

The session that was extracted from the request object.



64
65
66
# File 'lib/merb-core/dispatch/session.rb', line 64

def session(session_store = nil)
  request.session(session_store)
end