Subversion Info

Rev
437
Last Checked In
2008-03-28 00:49:20 (2 weeks ago)
Checked in by
deveiant

Parent

Included Modules

Class Index

Quicksearch

Arrow::Session::Id

Session ID class for in Arrow::Session objects.

Constants

SVNRev
SVN Revision
SVNId
SVN Id

Public Class Methods

create( uri, request, idstring=nil ) click to toggle source

Create a new Arrow::Session::Id object for the given request (an Apache::Request) of the type specified by uri.

    # File /Users/ged/source/ruby/Arrow/lib/arrow/session/id.rb, line 53
53:     def self::create( uri, request, idstring=nil )
54:         uri = Arrow::Session.parse_uri( uri ) if uri.is_a?( String )
55:         super( uri.scheme.dup, uri, request, idstring )
56:     end
derivativeDirs() click to toggle source

Returns the Array of directories to search for derivatives; part of the PluginFactory interface.

    # File /Users/ged/source/ruby/Arrow/lib/arrow/session/id.rb, line 46
46:     def self::derivativeDirs
47:         [ 'arrow/session', 'arrow/session/id' ]
48:     end
generate( uri, request ) click to toggle source

Generate a new id string for the given request.

    # File /Users/ged/source/ruby/Arrow/lib/arrow/session/id.rb, line 60
60:     def self::generate( uri, request )
61:         raise NotImplementedError, "%s does not implement #generate" %
62:             self.name
63:     end
new( uri, request, idstring=nil ) click to toggle source

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.

    # File /Users/ged/source/ruby/Arrow/lib/arrow/session/id.rb, line 82
82:     def initialize( uri, request, idstring=nil )
83:         @new = true
84: 
85:         if idstring
86:             self.log.debug "Validating id %p" % [ idstring ]
87:             @str = self.class.validate( uri, idstring )
88:             self.log.debug "  validation %s" % [ @str ? "succeeded" : "failed" ]
89:             @new = false
90:         end
91:         
92:         @str ||= self.class.generate( uri, request )
93:         super()
94:     end
validate( uri, idstring ) click to toggle source

Validate the given idstring, returning an untainted copy of it if it‘s valid, or nil if it‘s not.

    # File /Users/ged/source/ruby/Arrow/lib/arrow/session/id.rb, line 68
68:     def self::validate( uri, idstring )
69:         raise NotImplementedError, "%s does not implement #validate" %
70:             self.name
71:     end

Public Instance Methods

new?() click to toggle source

Returns true if the id was generated for this request as opposed to being fetched from a cookie or the URL.

     # File /Users/ged/source/ruby/Arrow/lib/arrow/session/id.rb, line 110
110:     def new?
111:         @new ? true : false
112:     end
to_s() click to toggle source

Return the id as a String.

     # File /Users/ged/source/ruby/Arrow/lib/arrow/session/id.rb, line 103
103:     def to_s
104:         return @str
105:     end

secsequence

--- SEC00107

seccomment

--- ""

method_list

--- 
- methods: 
  - visibility: public
    aref: M000106
    name: create
    sourcecode: "    <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/session/id.rb, line 53</span>\n\
      53:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-keyword kw\">self</span><span class=\"ruby-operator\">::</span><span class=\"ruby-identifier\">create</span>( <span class=\"ruby-identifier\">uri</span>, <span class=\"ruby-identifier\">request</span>, <span class=\"ruby-identifier\">idstring</span>=<span class=\"ruby-keyword kw\">nil</span> )\n\
      54:         <span class=\"ruby-identifier\">uri</span> = <span class=\"ruby-constant\">Arrow</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">Session</span>.<span class=\"ruby-identifier\">parse_uri</span>( <span class=\"ruby-identifier\">uri</span> ) <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-identifier\">uri</span>.<span class=\"ruby-identifier\">is_a?</span>( <span class=\"ruby-constant\">String</span> )\n\
      55:         <span class=\"ruby-keyword kw\">super</span>( <span class=\"ruby-identifier\">uri</span>.<span class=\"ruby-identifier\">scheme</span>.<span class=\"ruby-identifier\">dup</span>, <span class=\"ruby-identifier\">uri</span>, <span class=\"ruby-identifier\">request</span>, <span class=\"ruby-identifier\">idstring</span> )\n\
      56:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Create a <a href="Id.html#M000109">new</a> <a
      href="Id.html">Arrow::Session::Id</a> object for the given <tt>request</tt>
      (an <a href="../../Apache/Request.html">Apache::Request</a>) of the type
      specified by <tt>uri</tt>.
      </p>
    params: ( uri, request, idstring=nil )
  - visibility: public
    aref: M000105
    name: derivativeDirs
    sourcecode: "    <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/session/id.rb, line 46</span>\n\
      46:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-keyword kw\">self</span><span class=\"ruby-operator\">::</span><span class=\"ruby-identifier\">derivativeDirs</span>\n\
      47:         [ <span class=\"ruby-value str\">'arrow/session'</span>, <span class=\"ruby-value str\">'arrow/session/id'</span> ]\n\
      48:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Returns the Array of directories to search for derivatives; part of the
      PluginFactory interface.
      </p>
    params: ()
  - visibility: public
    aref: M000107
    name: generate
    sourcecode: "    <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/session/id.rb, line 60</span>\n\
      60:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-keyword kw\">self</span><span class=\"ruby-operator\">::</span><span class=\"ruby-identifier\">generate</span>( <span class=\"ruby-identifier\">uri</span>, <span class=\"ruby-identifier\">request</span> )\n\
      61:         <span class=\"ruby-identifier\">raise</span> <span class=\"ruby-constant\">NotImplementedError</span>, <span class=\"ruby-value str\">&quot;%s does not implement #generate&quot;</span> <span class=\"ruby-operator\">%</span>\n\
      62:             <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">name</span>\n\
      63:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Generate a <a href="Id.html#M000109">new</a> id string for the given
      <tt>request</tt>.
      </p>
    params: ( uri, request )
  - visibility: public
    aref: M000109
    name: new
    sourcecode: "    <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/session/id.rb, line 82</span>\n\
      82:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">initialize</span>( <span class=\"ruby-identifier\">uri</span>, <span class=\"ruby-identifier\">request</span>, <span class=\"ruby-identifier\">idstring</span>=<span class=\"ruby-keyword kw\">nil</span> )\n\
      83:         <span class=\"ruby-ivar\">@new</span> = <span class=\"ruby-keyword kw\">true</span>\n\
      84: \n\
      85:         <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-identifier\">idstring</span>\n\
      86:             <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">log</span>.<span class=\"ruby-identifier\">debug</span> <span class=\"ruby-value str\">&quot;Validating id %p&quot;</span> <span class=\"ruby-operator\">%</span> [ <span class=\"ruby-identifier\">idstring</span> ]\n\
      87:             <span class=\"ruby-ivar\">@str</span> = <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">class</span>.<span class=\"ruby-identifier\">validate</span>( <span class=\"ruby-identifier\">uri</span>, <span class=\"ruby-identifier\">idstring</span> )\n\
      88:             <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">log</span>.<span class=\"ruby-identifier\">debug</span> <span class=\"ruby-value str\">&quot;  validation %s&quot;</span> <span class=\"ruby-operator\">%</span> [ <span class=\"ruby-ivar\">@str</span> <span class=\"ruby-operator\">?</span> <span class=\"ruby-value str\">&quot;succeeded&quot;</span> <span class=\"ruby-operator\">:</span> <span class=\"ruby-value str\">&quot;failed&quot;</span> ]\n\
      89:             <span class=\"ruby-ivar\">@new</span> = <span class=\"ruby-keyword kw\">false</span>\n\
      90:         <span class=\"ruby-keyword kw\">end</span>\n\
      91:         \n\
      92:         <span class=\"ruby-ivar\">@str</span> <span class=\"ruby-operator\">||=</span> <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">class</span>.<span class=\"ruby-identifier\">generate</span>( <span class=\"ruby-identifier\">uri</span>, <span class=\"ruby-identifier\">request</span> )\n\
      93:         <span class=\"ruby-keyword kw\">super</span>()\n\
      94:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Create a <a href="Id.html#M000109">new</a> <a
      href="Id.html">Arrow::Session::Id</a> object. If the <tt>idstring</tt> is
      given, it will be used as the unique key for this session. If it is not
      specified, a <a href="Id.html#M000109">new</a> one will be generated.
      </p>
    params: ( uri, request, idstring=nil )
  - visibility: public
    aref: M000108
    name: validate
    sourcecode: "    <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/session/id.rb, line 68</span>\n\
      68:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-keyword kw\">self</span><span class=\"ruby-operator\">::</span><span class=\"ruby-identifier\">validate</span>( <span class=\"ruby-identifier\">uri</span>, <span class=\"ruby-identifier\">idstring</span> )\n\
      69:         <span class=\"ruby-identifier\">raise</span> <span class=\"ruby-constant\">NotImplementedError</span>, <span class=\"ruby-value str\">&quot;%s does not implement #validate&quot;</span> <span class=\"ruby-operator\">%</span>\n\
      70:             <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">name</span>\n\
      71:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Validate the given <tt>idstring</tt>, returning an untainted copy of it if
      it&#8216;s valid, or <tt>nil</tt> if it&#8216;s not.
      </p>
    params: ( uri, idstring )
  category: Class
  type: Public
- methods: 
  - visibility: public
    aref: M000111
    name: new?
    sourcecode: "     <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/session/id.rb, line 110</span>\n\
      110:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">new?</span>\n\
      111:         <span class=\"ruby-ivar\">@new</span> <span class=\"ruby-operator\">?</span> <span class=\"ruby-keyword kw\">true</span> <span class=\"ruby-operator\">:</span> <span class=\"ruby-keyword kw\">false</span>\n\
      112:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Returns <tt>true</tt> if the id was generated for this request as opposed
      to being fetched from a cookie or the URL.
      </p>
    params: ()
  - visibility: public
    aref: M000110
    name: to_s
    sourcecode: "     <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/session/id.rb, line 103</span>\n\
      103:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">to_s</span>\n\
      104:         <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-ivar\">@str</span>\n\
      105:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Return the id as a String.
      </p>
    params: ()
  category: Instance
  type: Public

sectitle

--- 

constants

--- 
- name: SVNRev
  desc: |+
    
    SVN Revision
    
  value: "%q$Rev: 437 $"
- name: SVNId
  desc: |+
    
    SVN <a href="Id.html">Id</a>
    
  value: "%q$Id: id.rb 437 2008-03-28 00:49:20Z deveiant $"

[Validate]

Generated with the Darkfish Rdoc Generator.