Class: Wee::AbstractSession
- Inherits:
-
RequestHandler
- Object
- RequestHandler
- Wee::AbstractSession
- Defined in:
- lib/wee/abstractsession.rb,
lib/wee/continuation/session.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from RequestHandler
#application, #expire_after, #id, #max_lifetime, #max_requests
Class Method Summary collapse
Instance Method Summary collapse
-
#current_context ⇒ Object
Returns the current context.
-
#get_property(prop, klass) ⇒ Object
Returns an “owned” property for the given
klass. -
#handle_request(context) ⇒ Object
Called by Wee::Application to send the session a request.
-
#initialize ⇒ AbstractSession
constructor
A new instance of AbstractSession.
- #properties ⇒ Object
- #properties=(props) ⇒ Object
Methods inherited from RequestHandler
#alive?, #statistics, #teminate
Constructor Details
#initialize ⇒ AbstractSession
Returns a new instance of AbstractSession.
9 10 11 12 13 14 |
# File 'lib/wee/abstractsession.rb', line 9 def initialize # to serialize the requests we need a mutex @mutex = Mutex.new super() end |
Class Method Details
.current ⇒ Object
5 6 7 |
# File 'lib/wee/abstractsession.rb', line 5 def self.current Thread.current[:wee_session] || (raise "Not in session") end |
Instance Method Details
#current_context ⇒ Object
Returns the current context.
18 19 20 |
# File 'lib/wee/abstractsession.rb', line 18 def current_context @context end |
#get_property(prop, klass) ⇒ Object
Returns an “owned” property for the given klass.
88 89 90 91 92 93 94 |
# File 'lib/wee/abstractsession.rb', line 88 def get_property(prop, klass) if self.properties self.properties.fetch(klass, {})[prop] else nil end end |
#handle_request(context) ⇒ Object
Called by Wee::Application to send the session a request.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/wee/abstractsession.rb', line 24 def handle_request(context) with_session { @mutex.synchronize { begin @context = context super awake process_request sleep ensure @context = nil # clean up end } } rescue Exception => exn set_response(context, Wee::ErrorResponse.new(exn)) end |
#properties ⇒ Object
83 |
# File 'lib/wee/abstractsession.rb', line 83 def properties() @__properties end |
#properties=(props) ⇒ Object
84 |
# File 'lib/wee/abstractsession.rb', line 84 def properties=(props) @__properties = props end |