Class: Arrow::Session::Id
- Inherits:
-
Arrow::Object
- Object
- Arrow::Object
- Arrow::Session::Id
- Includes:
- PluginFactory
- Defined in:
- lib/arrow/session/id.rb
Overview
The Arrow::Session::Id class, a derivative of Arrow::Object. Instances of concrete derivatives of this class are used as session IDs in Arrow::Session objects.
Authors
Michael Granger
Please see the file LICENSE in the top-level directory for licensing details.
Direct Known Subclasses
Class Method Summary
-
+ (Object) create(uri, request, idstring = nil)
Create a new Arrow::Session::Id object for the given request (an Apache::Request) of the type specified by uri.
-
+ (Object) derivativeDirs
Returns the Array of directories to search for derivatives; part of the PluginFactory interface.
-
+ (Object) generate(uri, request)
Generate a new id string for the given request.
-
+ (Object) validate(uri, idstring)
Validate the given idstring, returning an untainted copy of it if it’s valid, or nil if it’s not.
Instance Method Summary
-
- (Id) initialize(uri, request, idstring = nil)
constructor
Create a new Arrow::Session::Id object.
-
- (Boolean) new?
Returns true if the id was generated for this request as opposed to being fetched from a cookie or the URL.
-
- (Object) to_s
Return the id as a String.
Methods inherited from Arrow::Object
deprecate_class_method, deprecate_method, inherited
Methods included from Arrow::Loggable
Constructor Details
- (Id) initialize(uri, request, idstring = nil)
Create a new Arrow::Session::Id object. If the idstring is given, it will be used as the unique key for this session. If it is not specified, a new one will be generated.
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/arrow/session/id.rb', line 65 def initialize( uri, request, idstring=nil ) @new = true if idstring self.log.debug "Validating id %p" % [ idstring ] @str = self.class.validate( uri, idstring ) self.log.debug " validation %s" % [ @str ? "succeeded" : "failed" ] @new = false end @str ||= self.class.generate( uri, request ) super() end |
Class Method Details
+ (Object) create(uri, request, idstring = nil)
Create a new Arrow::Session::Id object for the given request (an Apache::Request) of the type specified by uri.
36 37 38 39 |
# File 'lib/arrow/session/id.rb', line 36 def self::create( uri, request, idstring=nil ) uri = Arrow::Session.parse_uri( uri ) if uri.is_a?( String ) super( uri.scheme.dup, uri, request, idstring ) end |
+ (Object) derivativeDirs
Returns the Array of directories to search for derivatives; part of the PluginFactory interface.
29 30 31 |
# File 'lib/arrow/session/id.rb', line 29 def self::derivativeDirs [ 'arrow/session', 'arrow/session/id' ] end |
+ (Object) generate(uri, request)
Generate a new id string for the given request.
43 44 45 46 |
# File 'lib/arrow/session/id.rb', line 43 def self::generate( uri, request ) raise NotImplementedError, "%s does not implement #generate" % self.name end |
+ (Object) validate(uri, idstring)
Validate the given idstring, returning an untainted copy of it if it’s valid, or nil if it’s not.
51 52 53 54 |
# File 'lib/arrow/session/id.rb', line 51 def self::validate( uri, idstring ) raise NotImplementedError, "%s does not implement #validate" % self.name end |
Instance Method Details
- (Boolean) new?
Returns true if the id was generated for this request as opposed to being fetched from a cookie or the URL.
93 94 95 |
# File 'lib/arrow/session/id.rb', line 93 def new? @new ? true : false end |
- (Object) to_s
Return the id as a String.
86 87 88 |
# File 'lib/arrow/session/id.rb', line 86 def to_s return @str end |