This provides a container for maintaining state across multiple transactions.
(Not documented)
Configure the session class‘s factory with the given Arrow::Config object.
# File /Users/ged/source/ruby/Arrow/lib/arrow/session.rb, line 71 71: def self::configure( config ) 72: @config = config.dup 73: Arrow::Logger[self].debug "Done. Session config is: %p" % @config 74: end
Create a new session for the specified request.
# File /Users/ged/source/ruby/Arrow/lib/arrow/session.rb, line 78 78: def self::create( txn, configHash={} ) 79: # Merge the incoming config with the factory's 80: sconfig = @config.merge( configHash ) 81: Arrow::Logger[self].debug "Merged config is: %p" % sconfig 82: 83: # Create a new id and backing store object 84: idobj = self.create_id( sconfig, txn ) 85: store = self.create_store( sconfig, idobj ) 86: lock = self.create_lock( sconfig, store, idobj ) 87: 88: # Create the session cookie 89: scookie = self.create_session_cookie( txn, sconfig, idobj, store, lock ) 90: 91: return new( idobj, lock, store, txn, scookie ) 92: end
Create an Arrow::Session::Id object for the given txn, with the particulars dictated by the specified config.
# File /Users/ged/source/ruby/Arrow/lib/arrow/session.rb, line 111 111: def self::create_id( config, txn ) 112: cookie_name = config.idName 113: 114: # Fetch the id from the request, either from the session cookie or 115: # as a parameter if the cookie doesn't exist. 116: if txn.request_cookies.include?( cookie_name ) 117: Arrow::Logger[self].debug "Found an existing session cookie (%s)" % 118: [ cookie_name ] 119: idstring = txn.request_cookies[ cookie_name ].value 120: else 121: Arrow::Logger[self].debug \ 122: "No existing session cookie (%s); looking for one in a request parameter" % 123: [ cookie_name] 124: idstring = txn.param( cookie_name ) 125: end 126: 127: Arrow::Logger[self].debug "Creating a session id object: %p" % config.idType 128: return Arrow::Session::Id.create( config.idType, txn.request, idstring ) 129: end
Create an Arrow::Session::Lock object for the specified store and id.
# File /Users/ged/source/ruby/Arrow/lib/arrow/session.rb, line 142 142: def self::create_lock( config, store, id ) 143: 144: lockuri = Arrow::Session.parse_uri( config.lockType ) 145: lock = nil 146: 147: # If the configuration says to use the recommended locker, ask the 148: # backing store for a lock object. 149: if lockuri.scheme == 'recommended' 150: Arrow::Logger[self].debug "Creating recommended lock" 151: lock = store.create_recommended_lock( id ) or 152: raise Arrow::SessionError, "No recommended locker for %s" % 153: store.class.name 154: else 155: Arrow::Logger[self].debug "Creating a session lock: %p" % lockuri 156: lock = Arrow::Session::Lock.create( lockuri, id ) 157: end 158: 159: return lock 160: end
Set the session cookie if we‘re really running under Apache.
# File /Users/ged/source/ruby/Arrow/lib/arrow/session.rb, line 96 96: def self::create_session_cookie( txn, config, id, store, lock ) 97: scookie = Arrow::Cookie.new( 98: config.idName, 99: id.to_s, 100: :expires => config.expires, 101: :path => '/' 102: ) 103: 104: Arrow::Logger[self].debug "Created cookie: %p" % scookie.to_s 105: return scookie 106: end
Create an Arrow::Session::Store object with the given id. The type and configuration of the store will be dictated by the specified config object.
# File /Users/ged/source/ruby/Arrow/lib/arrow/session.rb, line 135 135: def self::create_store( config, id ) 136: Arrow::Logger[self].debug "Creating a session store: %p" % config.storeType 137: return Arrow::Session::Store.create( config.storeType, id ) 138: end
Create a new Arrow::Session object for the given idobj (an Arrow::Session::Id object), using the given lock (an Arrow::Session::Locker object) for serializing access.
# File /Users/ged/source/ruby/Arrow/lib/arrow/session.rb, line 206 206: def initialize( idobj, lock, store, txn, cookie=nil ) 207: raise ArgumentError, "No id object" unless idobj 208: raise ArgumentError, "No lock object" unless lock 209: raise ArgumentError, "No store object" unless store 210: 211: self.log.debug "Initializing session with id: %p, lock: %p, store: %p" % 212: [ idobj, lock, store ] 213: 214: @id = idobj 215: @lock = lock 216: @store = store 217: @txn = txn 218: @cookie = cookie 219: 220: @store[ :_session_id ] = id.to_s 221: end
Parse the given string into a URI object, appending the path part if it doesn‘t exist.
# File /Users/ged/source/ruby/Arrow/lib/arrow/session.rb, line 62 62: def self::parse_uri( str ) 63: return str if str.is_a?( URI::Generic ) 64: str += ":." if /^\w+$/ =~ str 65: URI.parse( str ) 66: end
Create delegators that readlock the session store before accessing it.
# File /Users/ged/source/ruby/Arrow/lib/arrow/session.rb, line 176 176: def self::def_delegated_readers( *syms ) 177: syms.each do |sym| 178: define_method( sym ) do |*args| 179: @lock.read_lock 180: @store.send( sym, *args ) 181: end 182: end 183: end
Create delegators that writelock the session store before accessing it.
# File /Users/ged/source/ruby/Arrow/lib/arrow/session.rb, line 188 188: def self::def_delegated_writers( *syms ) 189: syms.each do |sym| 190: define_method( sym ) do |*args| 191: @lock.write_lock 192: @store.send( sym, *args ) 193: end 194: end 195: end
Clear all data from the session object.
# File /Users/ged/source/ruby/Arrow/lib/arrow/session.rb, line 252 252: def clear 253: @lock.with_write_lock do 254: @store.clear 255: @store[ :_session_id ] = @id.to_s 256: end 257: end
Enumerable iterface: iterate over the session‘s key/value pairs, calling the given block once for each pair.
# File /Users/ged/source/ruby/Arrow/lib/arrow/session.rb, line 262 262: def each( &block ) 263: raise LocalJumpError, "no block given" unless block 264: @lock.read_lock 265: @store.each( &block ) 266: end
Tell the session that it will not be used again in the current session.
# File /Users/ged/source/ruby/Arrow/lib/arrow/session.rb, line 286 286: def finish 287: @lock.release_all_locks 288: end
Delete the session
# File /Users/ged/source/ruby/Arrow/lib/arrow/session.rb, line 242 242: def remove 243: @lock.with_write_lock do 244: @store.remove 245: end 246: @lock.release_all_locks 247: @cookie.expires = Time.at(0) 248: end
Save the session to fixed storage and set the session cookie in the creating transaction‘s outgoing headers.
# File /Users/ged/source/ruby/Arrow/lib/arrow/session.rb, line 271 271: def save 272: begin 273: self.log.debug "Saving session data" 274: @store.save 275: self.log.debug "Writing session cookie (%p)" % [ @cookie ] 276: @txn.cookies[ self.class.session_cookie_name ] = @cookie 277: ensure 278: self.log.debug "Releasing all locks" 279: @lock.release_all_locks 280: end 281: end
--- SEC00123
--- ""
--- - name: config rw: R a_desc: "" - name: cookie rw: R a_desc: |+ The <a href="../Apache/Cookie.html">Apache::Cookie</a> object used to manipulate the session cookie. - name: id rw: R a_desc: |+ The session‘s unique identifier, an Apache::Session::Id object. - name: lock rw: R a_desc: |+ The session‘s lock object; an Apache::Session::Lock. - name: store rw: R a_desc: |+ The session‘s backing store; an Apache::Session::Store object.
--- - methods: - visibility: public aref: M000353 name: configure sourcecode: " <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/session.rb, line 71</span>\n\ 71: <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-keyword kw\">self</span><span class=\"ruby-operator\">::</span><span class=\"ruby-identifier\">configure</span>( <span class=\"ruby-identifier\">config</span> )\n\ 72: <span class=\"ruby-ivar\">@config</span> = <span class=\"ruby-identifier\">config</span>.<span class=\"ruby-identifier\">dup</span>\n\ 73: <span class=\"ruby-constant\">Arrow</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">Logger</span>[<span class=\"ruby-keyword kw\">self</span>].<span class=\"ruby-identifier\">debug</span> <span class=\"ruby-value str\">"Done. Session config is: %p"</span> <span class=\"ruby-operator\">%</span> <span class=\"ruby-ivar\">@config</span>\n\ 74: <span class=\"ruby-keyword kw\">end</span>" m_desc: |- <p> Configure the session class‘s factory with the given <a href="Config.html">Arrow::Config</a> object. </p> params: ( config ) - visibility: public aref: M000354 name: create sourcecode: " <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/session.rb, line 78</span>\n\ 78: <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\">txn</span>, <span class=\"ruby-identifier\">configHash</span>={} )\n\ 79: <span class=\"ruby-comment cmt\"># Merge the incoming config with the factory's</span>\n\ 80: <span class=\"ruby-identifier\">sconfig</span> = <span class=\"ruby-ivar\">@config</span>.<span class=\"ruby-identifier\">merge</span>( <span class=\"ruby-identifier\">configHash</span> )\n\ 81: <span class=\"ruby-constant\">Arrow</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">Logger</span>[<span class=\"ruby-keyword kw\">self</span>].<span class=\"ruby-identifier\">debug</span> <span class=\"ruby-value str\">"Merged config is: %p"</span> <span class=\"ruby-operator\">%</span> <span class=\"ruby-identifier\">sconfig</span>\n\ 82: \n\ 83: <span class=\"ruby-comment cmt\"># Create a new id and backing store object</span>\n\ 84: <span class=\"ruby-identifier\">idobj</span> = <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">create_id</span>( <span class=\"ruby-identifier\">sconfig</span>, <span class=\"ruby-identifier\">txn</span> )\n\ 85: <span class=\"ruby-identifier\">store</span> = <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">create_store</span>( <span class=\"ruby-identifier\">sconfig</span>, <span class=\"ruby-identifier\">idobj</span> )\n\ 86: <span class=\"ruby-identifier\">lock</span> = <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">create_lock</span>( <span class=\"ruby-identifier\">sconfig</span>, <span class=\"ruby-identifier\">store</span>, <span class=\"ruby-identifier\">idobj</span> )\n\ 87: \n\ 88: <span class=\"ruby-comment cmt\"># Create the session cookie</span>\n\ 89: <span class=\"ruby-identifier\">scookie</span> = <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">create_session_cookie</span>( <span class=\"ruby-identifier\">txn</span>, <span class=\"ruby-identifier\">sconfig</span>, <span class=\"ruby-identifier\">idobj</span>, <span class=\"ruby-identifier\">store</span>, <span class=\"ruby-identifier\">lock</span> )\n\ 90: \n\ 91: <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-identifier\">new</span>( <span class=\"ruby-identifier\">idobj</span>, <span class=\"ruby-identifier\">lock</span>, <span class=\"ruby-identifier\">store</span>, <span class=\"ruby-identifier\">txn</span>, <span class=\"ruby-identifier\">scookie</span> )\n\ 92: <span class=\"ruby-keyword kw\">end</span>" m_desc: |- <p> Create a <a href="Session.html#M000362">new</a> session for the specified <tt>request</tt>. </p> params: ( txn, configHash={} ) - visibility: public aref: M000356 name: create_id sourcecode: " <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/session.rb, line 111</span>\n\ 111: <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-keyword kw\">self</span><span class=\"ruby-operator\">::</span><span class=\"ruby-identifier\">create_id</span>( <span class=\"ruby-identifier\">config</span>, <span class=\"ruby-identifier\">txn</span> )\n\ 112: <span class=\"ruby-identifier\">cookie_name</span> = <span class=\"ruby-identifier\">config</span>.<span class=\"ruby-identifier\">idName</span>\n\ 113: \n\ 114: <span class=\"ruby-comment cmt\"># Fetch the id from the request, either from the session cookie or</span>\n\ 115: <span class=\"ruby-comment cmt\"># as a parameter if the cookie doesn't exist.</span>\n\ 116: <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-identifier\">txn</span>.<span class=\"ruby-identifier\">request_cookies</span>.<span class=\"ruby-identifier\">include?</span>( <span class=\"ruby-identifier\">cookie_name</span> )\n\ 117: <span class=\"ruby-constant\">Arrow</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">Logger</span>[<span class=\"ruby-keyword kw\">self</span>].<span class=\"ruby-identifier\">debug</span> <span class=\"ruby-value str\">"Found an existing session cookie (%s)"</span> <span class=\"ruby-operator\">%</span>\n\ 118: [ <span class=\"ruby-identifier\">cookie_name</span> ]\n\ 119: <span class=\"ruby-identifier\">idstring</span> = <span class=\"ruby-identifier\">txn</span>.<span class=\"ruby-identifier\">request_cookies</span>[ <span class=\"ruby-identifier\">cookie_name</span> ].<span class=\"ruby-identifier\">value</span>\n\ 120: <span class=\"ruby-keyword kw\">else</span>\n\ 121: <span class=\"ruby-constant\">Arrow</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">Logger</span>[<span class=\"ruby-keyword kw\">self</span>].<span class=\"ruby-identifier\">debug</span> \\\n\ 122: <span class=\"ruby-value str\">"No existing session cookie (%s); looking for one in a request parameter"</span> <span class=\"ruby-operator\">%</span>\n\ 123: [ <span class=\"ruby-identifier\">cookie_name</span>]\n\ 124: <span class=\"ruby-identifier\">idstring</span> = <span class=\"ruby-identifier\">txn</span>.<span class=\"ruby-identifier\">param</span>( <span class=\"ruby-identifier\">cookie_name</span> )\n\ 125: <span class=\"ruby-keyword kw\">end</span>\n\ 126: \n\ 127: <span class=\"ruby-constant\">Arrow</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">Logger</span>[<span class=\"ruby-keyword kw\">self</span>].<span class=\"ruby-identifier\">debug</span> <span class=\"ruby-value str\">"Creating a session id object: %p"</span> <span class=\"ruby-operator\">%</span> <span class=\"ruby-identifier\">config</span>.<span class=\"ruby-identifier\">idType</span>\n\ 128: <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-constant\">Arrow</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">Session</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">Id</span>.<span class=\"ruby-identifier\">create</span>( <span class=\"ruby-identifier\">config</span>.<span class=\"ruby-identifier\">idType</span>, <span class=\"ruby-identifier\">txn</span>.<span class=\"ruby-identifier\">request</span>, <span class=\"ruby-identifier\">idstring</span> )\n\ 129: <span class=\"ruby-keyword kw\">end</span>" m_desc: |- <p> Create an <a href="Session/Id.html">Arrow::Session::Id</a> object for the given <tt>txn</tt>, with the particulars dictated by the specified <tt>config</tt>. </p> params: ( config, txn ) - visibility: public aref: M000358 name: create_lock sourcecode: " <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/session.rb, line 142</span>\n\ 142: <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-keyword kw\">self</span><span class=\"ruby-operator\">::</span><span class=\"ruby-identifier\">create_lock</span>( <span class=\"ruby-identifier\">config</span>, <span class=\"ruby-identifier\">store</span>, <span class=\"ruby-identifier\">id</span> )\n\ 143: \n\ 144: <span class=\"ruby-identifier\">lockuri</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\">config</span>.<span class=\"ruby-identifier\">lockType</span> )\n\ 145: <span class=\"ruby-identifier\">lock</span> = <span class=\"ruby-keyword kw\">nil</span>\n\ 146: \n\ 147: <span class=\"ruby-comment cmt\"># If the configuration says to use the recommended locker, ask the</span>\n\ 148: <span class=\"ruby-comment cmt\"># backing store for a lock object.</span>\n\ 149: <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-identifier\">lockuri</span>.<span class=\"ruby-identifier\">scheme</span> <span class=\"ruby-operator\">==</span> <span class=\"ruby-value str\">'recommended'</span>\n\ 150: <span class=\"ruby-constant\">Arrow</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">Logger</span>[<span class=\"ruby-keyword kw\">self</span>].<span class=\"ruby-identifier\">debug</span> <span class=\"ruby-value str\">"Creating recommended lock"</span>\n\ 151: <span class=\"ruby-identifier\">lock</span> = <span class=\"ruby-identifier\">store</span>.<span class=\"ruby-identifier\">create_recommended_lock</span>( <span class=\"ruby-identifier\">id</span> ) <span class=\"ruby-keyword kw\">or</span>\n\ 152: <span class=\"ruby-identifier\">raise</span> <span class=\"ruby-constant\">Arrow</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">SessionError</span>, <span class=\"ruby-value str\">"No recommended locker for %s"</span> <span class=\"ruby-operator\">%</span>\n\ 153: <span class=\"ruby-identifier\">store</span>.<span class=\"ruby-identifier\">class</span>.<span class=\"ruby-identifier\">name</span>\n\ 154: <span class=\"ruby-keyword kw\">else</span>\n\ 155: <span class=\"ruby-constant\">Arrow</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">Logger</span>[<span class=\"ruby-keyword kw\">self</span>].<span class=\"ruby-identifier\">debug</span> <span class=\"ruby-value str\">"Creating a session lock: %p"</span> <span class=\"ruby-operator\">%</span> <span class=\"ruby-identifier\">lockuri</span>\n\ 156: <span class=\"ruby-identifier\">lock</span> = <span class=\"ruby-constant\">Arrow</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">Session</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">Lock</span>.<span class=\"ruby-identifier\">create</span>( <span class=\"ruby-identifier\">lockuri</span>, <span class=\"ruby-identifier\">id</span> )\n\ 157: <span class=\"ruby-keyword kw\">end</span>\n\ 158: \n\ 159: <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-identifier\">lock</span>\n\ 160: <span class=\"ruby-keyword kw\">end</span>" m_desc: |- <p> Create an <a href="Session/Lock.html">Arrow::Session::Lock</a> object for the specified <tt>store</tt> and <tt>id</tt>. </p> params: ( config, store, id ) - visibility: public aref: M000355 name: create_session_cookie sourcecode: " <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/session.rb, line 96</span>\n 96: <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-keyword kw\">self</span><span class=\"ruby-operator\">::</span><span class=\"ruby-identifier\">create_session_cookie</span>( <span class=\"ruby-identifier\">txn</span>, <span class=\"ruby-identifier\">config</span>, <span class=\"ruby-identifier\">id</span>, <span class=\"ruby-identifier\">store</span>, <span class=\"ruby-identifier\">lock</span> )\n 97: <span class=\"ruby-identifier\">scookie</span> = <span class=\"ruby-constant\">Arrow</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">Cookie</span>.<span class=\"ruby-identifier\">new</span>(\n 98: <span class=\"ruby-identifier\">config</span>.<span class=\"ruby-identifier\">idName</span>,\n 99: <span class=\"ruby-identifier\">id</span>.<span class=\"ruby-identifier\">to_s</span>,\n\ 100: <span class=\"ruby-identifier\">:expires</span> =<span class=\"ruby-operator\">></span> <span class=\"ruby-identifier\">config</span>.<span class=\"ruby-identifier\">expires</span>,\n\ 101: <span class=\"ruby-identifier\">:path</span> =<span class=\"ruby-operator\">></span> <span class=\"ruby-value str\">'/'</span>\n\ 102: )\n\ 103: \n\ 104: <span class=\"ruby-constant\">Arrow</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">Logger</span>[<span class=\"ruby-keyword kw\">self</span>].<span class=\"ruby-identifier\">debug</span> <span class=\"ruby-value str\">"Created cookie: %p"</span> <span class=\"ruby-operator\">%</span> <span class=\"ruby-identifier\">scookie</span>.<span class=\"ruby-identifier\">to_s</span>\n\ 105: <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-identifier\">scookie</span>\n\ 106: <span class=\"ruby-keyword kw\">end</span>" m_desc: |- <p> Set the session cookie if we‘re really running under Apache. </p> params: ( txn, config, id, store, lock ) - visibility: public aref: M000357 name: create_store sourcecode: " <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/session.rb, line 135</span>\n\ 135: <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-keyword kw\">self</span><span class=\"ruby-operator\">::</span><span class=\"ruby-identifier\">create_store</span>( <span class=\"ruby-identifier\">config</span>, <span class=\"ruby-identifier\">id</span> )\n\ 136: <span class=\"ruby-constant\">Arrow</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">Logger</span>[<span class=\"ruby-keyword kw\">self</span>].<span class=\"ruby-identifier\">debug</span> <span class=\"ruby-value str\">"Creating a session store: %p"</span> <span class=\"ruby-operator\">%</span> <span class=\"ruby-identifier\">config</span>.<span class=\"ruby-identifier\">storeType</span>\n\ 137: <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-constant\">Arrow</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">Session</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">Store</span>.<span class=\"ruby-identifier\">create</span>( <span class=\"ruby-identifier\">config</span>.<span class=\"ruby-identifier\">storeType</span>, <span class=\"ruby-identifier\">id</span> )\n\ 138: <span class=\"ruby-keyword kw\">end</span>" m_desc: |- <p> Create an <a href="Session/Store.html">Arrow::Session::Store</a> object with the given <tt>id</tt>. The type and configuration of the store will be dictated by the specified <tt>config</tt> object. </p> params: ( config, id ) - visibility: public aref: M000362 name: new sourcecode: " <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/session.rb, line 206</span>\n\ 206: <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">initialize</span>( <span class=\"ruby-identifier\">idobj</span>, <span class=\"ruby-identifier\">lock</span>, <span class=\"ruby-identifier\">store</span>, <span class=\"ruby-identifier\">txn</span>, <span class=\"ruby-identifier\">cookie</span>=<span class=\"ruby-keyword kw\">nil</span> )\n\ 207: <span class=\"ruby-identifier\">raise</span> <span class=\"ruby-constant\">ArgumentError</span>, <span class=\"ruby-value str\">"No id object"</span> <span class=\"ruby-keyword kw\">unless</span> <span class=\"ruby-identifier\">idobj</span>\n\ 208: <span class=\"ruby-identifier\">raise</span> <span class=\"ruby-constant\">ArgumentError</span>, <span class=\"ruby-value str\">"No lock object"</span> <span class=\"ruby-keyword kw\">unless</span> <span class=\"ruby-identifier\">lock</span>\n\ 209: <span class=\"ruby-identifier\">raise</span> <span class=\"ruby-constant\">ArgumentError</span>, <span class=\"ruby-value str\">"No store object"</span> <span class=\"ruby-keyword kw\">unless</span> <span class=\"ruby-identifier\">store</span>\n\ 210: \n\ 211: <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">log</span>.<span class=\"ruby-identifier\">debug</span> <span class=\"ruby-value str\">"Initializing session with id: %p, lock: %p, store: %p"</span> <span class=\"ruby-operator\">%</span>\n\ 212: [ <span class=\"ruby-identifier\">idobj</span>, <span class=\"ruby-identifier\">lock</span>, <span class=\"ruby-identifier\">store</span> ]\n\ 213: \n\ 214: <span class=\"ruby-ivar\">@id</span> = <span class=\"ruby-identifier\">idobj</span>\n\ 215: <span class=\"ruby-ivar\">@lock</span> = <span class=\"ruby-identifier\">lock</span>\n\ 216: <span class=\"ruby-ivar\">@store</span> = <span class=\"ruby-identifier\">store</span>\n\ 217: <span class=\"ruby-ivar\">@txn</span> = <span class=\"ruby-identifier\">txn</span>\n\ 218: <span class=\"ruby-ivar\">@cookie</span> = <span class=\"ruby-identifier\">cookie</span>\n\ 219: \n\ 220: <span class=\"ruby-ivar\">@store</span>[ <span class=\"ruby-identifier\">:_session_id</span> ] = <span class=\"ruby-identifier\">id</span>.<span class=\"ruby-identifier\">to_s</span>\n\ 221: <span class=\"ruby-keyword kw\">end</span>" m_desc: |- <p> Create a <a href="Session.html#M000362">new</a> <a href="Session.html">Arrow::Session</a> object for the given <tt>idobj</tt> (an <a href="Session/Id.html">Arrow::Session::Id</a> object), using the given <tt>lock</tt> (an Arrow::Session::Locker object) for serializing access. </p> params: ( idobj, lock, store, txn, cookie=nil ) - visibility: public aref: M000352 name: parse_uri sourcecode: " <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/session.rb, line 62</span>\n\ 62: <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-keyword kw\">self</span><span class=\"ruby-operator\">::</span><span class=\"ruby-identifier\">parse_uri</span>( <span class=\"ruby-identifier\">str</span> )\n\ 63: <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-identifier\">str</span> <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-identifier\">str</span>.<span class=\"ruby-identifier\">is_a?</span>( <span class=\"ruby-constant\">URI</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">Generic</span> )\n\ 64: <span class=\"ruby-identifier\">str</span> <span class=\"ruby-operator\">+=</span> <span class=\"ruby-value str\">":."</span> <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-regexp re\">/^\\w+$/</span> <span class=\"ruby-operator\">=~</span> <span class=\"ruby-identifier\">str</span>\n\ 65: <span class=\"ruby-constant\">URI</span>.<span class=\"ruby-identifier\">parse</span>( <span class=\"ruby-identifier\">str</span> )\n\ 66: <span class=\"ruby-keyword kw\">end</span>" m_desc: |- <p> Parse the given string into a URI object, appending the path part if it doesn‘t exist. </p> params: ( str ) - visibility: public aref: M000359 name: session_cookie_name sourcecode: " <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/session.rb, line 164</span>\n\ 164: <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-keyword kw\">self</span><span class=\"ruby-operator\">::</span><span class=\"ruby-identifier\">session_cookie_name</span>\n\ 165: <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-ivar\">@config</span>.<span class=\"ruby-identifier\">idName</span>\n\ 166: <span class=\"ruby-keyword kw\">end</span>" m_desc: |- <p> Return the configured name of the session cookie. </p> params: () category: Class type: Public - methods: - visibility: protected aref: M000360 name: def_delegated_readers sourcecode: " <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/session.rb, line 176</span>\n\ 176: <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-keyword kw\">self</span><span class=\"ruby-operator\">::</span><span class=\"ruby-identifier\">def_delegated_readers</span>( <span class=\"ruby-operator\">*</span><span class=\"ruby-identifier\">syms</span> )\n\ 177: <span class=\"ruby-identifier\">syms</span>.<span class=\"ruby-identifier\">each</span> <span class=\"ruby-keyword kw\">do</span> <span class=\"ruby-operator\">|</span><span class=\"ruby-identifier\">sym</span><span class=\"ruby-operator\">|</span>\n\ 178: <span class=\"ruby-identifier\">define_method</span>( <span class=\"ruby-identifier\">sym</span> ) <span class=\"ruby-keyword kw\">do</span> <span class=\"ruby-operator\">|</span><span class=\"ruby-operator\">*</span><span class=\"ruby-identifier\">args</span><span class=\"ruby-operator\">|</span>\n\ 179: <span class=\"ruby-ivar\">@lock</span>.<span class=\"ruby-identifier\">read_lock</span>\n\ 180: <span class=\"ruby-ivar\">@store</span>.<span class=\"ruby-identifier\">send</span>( <span class=\"ruby-identifier\">sym</span>, <span class=\"ruby-operator\">*</span><span class=\"ruby-identifier\">args</span> )\n\ 181: <span class=\"ruby-keyword kw\">end</span>\n\ 182: <span class=\"ruby-keyword kw\">end</span>\n\ 183: <span class=\"ruby-keyword kw\">end</span>" m_desc: |- <p> Create delegators that readlock the session store before accessing it. </p> params: ( *syms ) - visibility: protected aref: M000361 name: def_delegated_writers sourcecode: " <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/session.rb, line 188</span>\n\ 188: <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-keyword kw\">self</span><span class=\"ruby-operator\">::</span><span class=\"ruby-identifier\">def_delegated_writers</span>( <span class=\"ruby-operator\">*</span><span class=\"ruby-identifier\">syms</span> )\n\ 189: <span class=\"ruby-identifier\">syms</span>.<span class=\"ruby-identifier\">each</span> <span class=\"ruby-keyword kw\">do</span> <span class=\"ruby-operator\">|</span><span class=\"ruby-identifier\">sym</span><span class=\"ruby-operator\">|</span>\n\ 190: <span class=\"ruby-identifier\">define_method</span>( <span class=\"ruby-identifier\">sym</span> ) <span class=\"ruby-keyword kw\">do</span> <span class=\"ruby-operator\">|</span><span class=\"ruby-operator\">*</span><span class=\"ruby-identifier\">args</span><span class=\"ruby-operator\">|</span>\n\ 191: <span class=\"ruby-ivar\">@lock</span>.<span class=\"ruby-identifier\">write_lock</span>\n\ 192: <span class=\"ruby-ivar\">@store</span>.<span class=\"ruby-identifier\">send</span>( <span class=\"ruby-identifier\">sym</span>, <span class=\"ruby-operator\">*</span><span class=\"ruby-identifier\">args</span> )\n\ 193: <span class=\"ruby-keyword kw\">end</span>\n\ 194: <span class=\"ruby-keyword kw\">end</span>\n\ 195: <span class=\"ruby-keyword kw\">end</span>" m_desc: |- <p> Create delegators that writelock the session store before accessing it. </p> params: ( *syms ) category: Class type: Protected - methods: - visibility: public aref: M000364 name: clear sourcecode: " <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/session.rb, line 252</span>\n\ 252: <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">clear</span>\n\ 253: <span class=\"ruby-ivar\">@lock</span>.<span class=\"ruby-identifier\">with_write_lock</span> <span class=\"ruby-keyword kw\">do</span>\n\ 254: <span class=\"ruby-ivar\">@store</span>.<span class=\"ruby-identifier\">clear</span>\n\ 255: <span class=\"ruby-ivar\">@store</span>[ <span class=\"ruby-identifier\">:_session_id</span> ] = <span class=\"ruby-ivar\">@id</span>.<span class=\"ruby-identifier\">to_s</span>\n\ 256: <span class=\"ruby-keyword kw\">end</span>\n\ 257: <span class=\"ruby-keyword kw\">end</span>" m_desc: |- <p> Clear all data from the session object. </p> params: () - visibility: public aref: M000365 name: each sourcecode: " <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/session.rb, line 262</span>\n\ 262: <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">each</span>( <span class=\"ruby-operator\">&</span><span class=\"ruby-identifier\">block</span> )\n\ 263: <span class=\"ruby-identifier\">raise</span> <span class=\"ruby-constant\">LocalJumpError</span>, <span class=\"ruby-value str\">"no block given"</span> <span class=\"ruby-keyword kw\">unless</span> <span class=\"ruby-identifier\">block</span>\n\ 264: <span class=\"ruby-ivar\">@lock</span>.<span class=\"ruby-identifier\">read_lock</span>\n\ 265: <span class=\"ruby-ivar\">@store</span>.<span class=\"ruby-identifier\">each</span>( <span class=\"ruby-operator\">&</span><span class=\"ruby-identifier\">block</span> )\n\ 266: <span class=\"ruby-keyword kw\">end</span>" m_desc: |- <p> Enumerable iterface: iterate over the session‘s key/value pairs, calling the given block once for <a href="Session.html#M000365">each</a> pair. </p> params: ( &block ) - visibility: public aref: M000367 name: finish sourcecode: " <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/session.rb, line 286</span>\n\ 286: <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">finish</span>\n\ 287: <span class=\"ruby-ivar\">@lock</span>.<span class=\"ruby-identifier\">release_all_locks</span>\n\ 288: <span class=\"ruby-keyword kw\">end</span>" m_desc: |- <p> Tell the session that it will not be used again in the current session. </p> params: () - visibility: public aref: M000363 name: remove sourcecode: " <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/session.rb, line 242</span>\n\ 242: <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">remove</span>\n\ 243: <span class=\"ruby-ivar\">@lock</span>.<span class=\"ruby-identifier\">with_write_lock</span> <span class=\"ruby-keyword kw\">do</span>\n\ 244: <span class=\"ruby-ivar\">@store</span>.<span class=\"ruby-identifier\">remove</span>\n\ 245: <span class=\"ruby-keyword kw\">end</span>\n\ 246: <span class=\"ruby-ivar\">@lock</span>.<span class=\"ruby-identifier\">release_all_locks</span>\n\ 247: <span class=\"ruby-ivar\">@cookie</span>.<span class=\"ruby-identifier\">expires</span> = <span class=\"ruby-constant\">Time</span>.<span class=\"ruby-identifier\">at</span>(<span class=\"ruby-value\">0</span>)\n\ 248: <span class=\"ruby-keyword kw\">end</span>" m_desc: |- <p> Delete the session </p> params: () - visibility: public aref: M000366 name: save sourcecode: " <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/session.rb, line 271</span>\n\ 271: <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">save</span>\n\ 272: <span class=\"ruby-keyword kw\">begin</span>\n\ 273: <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">log</span>.<span class=\"ruby-identifier\">debug</span> <span class=\"ruby-value str\">"Saving session data"</span>\n\ 274: <span class=\"ruby-ivar\">@store</span>.<span class=\"ruby-identifier\">save</span>\n\ 275: <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">log</span>.<span class=\"ruby-identifier\">debug</span> <span class=\"ruby-value str\">"Writing session cookie (%p)"</span> <span class=\"ruby-operator\">%</span> [ <span class=\"ruby-ivar\">@cookie</span> ]\n\ 276: <span class=\"ruby-ivar\">@txn</span>.<span class=\"ruby-identifier\">cookies</span>[ <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">class</span>.<span class=\"ruby-identifier\">session_cookie_name</span> ] = <span class=\"ruby-ivar\">@cookie</span>\n\ 277: <span class=\"ruby-keyword kw\">ensure</span>\n\ 278: <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">log</span>.<span class=\"ruby-identifier\">debug</span> <span class=\"ruby-value str\">"Releasing all locks"</span>\n\ 279: <span class=\"ruby-ivar\">@lock</span>.<span class=\"ruby-identifier\">release_all_locks</span>\n\ 280: <span class=\"ruby-keyword kw\">end</span>\n\ 281: <span class=\"ruby-keyword kw\">end</span>" m_desc: |- <p> Save the session to fixed storage and set the session cookie in the creating transaction‘s outgoing headers. </p> params: () category: Instance type: Public
---
--- - name: SVNRev desc: |+ SVN Revision value: "%q$Rev: 437 $" - name: SVNId desc: |+ SVN Id value: "%q$Id: session.rb 437 2008-03-28 00:49:20Z deveiant $"
Generated with the Darkfish Rdoc Generator.