Class: Innate::Current
- Inherits:
-
Object
- Object
- Innate::Current
- Extended by:
- Trinity
- Defined in:
- /home/manveru/github/ramaze/ramaze.net/tmp/git/innate/lib/innate/current.rb
Overview
We track the current request/response/session (Trinity) in Thread.current so we can reach them from anywhere in the code without passing around the objects directly.
Direct Known Subclasses
Instance Method Summary (collapse)
-
- (Object) call(env)
Run setup and call the app.
-
- (Current) initialize(app, *rest)
constructor
A new instance of Current.
-
- (Object) setup(env, request = Request, response = Response, session = Session)
Setup new Request/Response/Session for this request/response cycle.
Methods included from Trinity
Methods included from StateAccessor
each, #state_accessor, #state_reader, #state_writer
Constructor Details
- (Current) initialize(app, *rest)
Returns a new instance of Current
11 12 13 14 15 16 17 |
# File '/home/manveru/github/ramaze/ramaze.net/tmp/git/innate/lib/innate/current.rb', line 11 def initialize(app, *rest) if rest.empty? @app = app else @app = Rack::Cascade.new([app, *rest]) end end |
Instance Method Details
- (Object) call(env)
Run setup and call the app
20 21 22 23 |
# File '/home/manveru/github/ramaze/ramaze.net/tmp/git/innate/lib/innate/current.rb', line 20 def call(env) setup(env) @app.call(env) end |
- (Object) setup(env, request = Request, response = Response, session = Session)
Setup new Request/Response/Session for this request/response cycle. The parameters are here to allow Ramaze to inject its own classes.
27 28 29 30 31 32 33 |
# File '/home/manveru/github/ramaze/ramaze.net/tmp/git/innate/lib/innate/current.rb', line 27 def setup(env, request = Request, response = Response, session = Session) current = Thread.current req = current[:request] = request.new(env) res = current[:response] = response.new current[:actions] = [] current[:session] = session.new(req, res) end |