Strelka::HTTPRequest::

Session

module
Included Modules
Strelka::Constants
Extended With
Configurability

The mixin that adds methods to Strelka::HTTPRequest for session management.

request.session?
request.session

Attributes

session_namespace[R]

The current session namespace

Public Class Methods

anchor
new( * )

Extension callback – add instance variables to extended objects.

# File lib/strelka/httprequest/session.rb, line 21
def initialize( * )
        super
        @session_namespace = nil
        @session = nil
end

Public Instance Methods

anchor
has_session?()
Alias for: session?
anchor
session()

Return the session associated with the request, creating it if necessary.

# File lib/strelka/httprequest/session.rb, line 60
def session
        unless @session
                @session = Strelka::App::Sessions.session_class.load_or_create( self )
                @session.namespace = self.session_namespace
        end

        return @session
end
anchor
session=( new_session )

Set the request's session object.

# File lib/strelka/httprequest/session.rb, line 71
def session=( new_session )
        new_session.namespace = self.session_namespace if new_session.respond_to?( :namespace )
        @session = new_session
end
anchor
session?()

Returns true if the request has an associated session object.

# File lib/strelka/httprequest/session.rb, line 47
def session?
        return @session || Strelka::App::Sessions.session_class.has_session_for?( self )
end
Also aliased as: has_session?
anchor
session_loaded?()

Returns true if the request has loaded its session.

# File lib/strelka/httprequest/session.rb, line 54
def session_loaded?
        return @session ? true : false
end
anchor
session_namespace=( namespace )

The namespace that will be used when creating a session for this request

# File lib/strelka/httprequest/session.rb, line 37
def session_namespace=( namespace )
        self.log.debug "Setting session namespace to %p" % [ namespace ]
        @session_namespace = namespace

        # If the session has already been created, switch its current namespace
        @session.namespace = namespace if @session
end