Class: Innate::Current

### Home Classes Methods

### In Files

- lib/innate/current.rb

### Parent

Object

### Methods

- ::new
- #call
- #setup

### Class/Module Index

Quicksearch

- Innate
- Innate::Action
- Innate::Adapter
- Innate::Cache
- Innate::Cache::API
- Innate::Cache::DRb
- Innate::Cache::FileBased
- Innate::Cache::Marshal
- Innate::Cache::Memory
- Innate::Cache::YAML
- Innate::Current
- Innate::Etanni
- Innate::Helper
- Innate::Helper::Aspect
- Innate::Helper::Aspect::SingletonMethods
- Innate::Helper::CGI
- Innate::Helper::Flash
- Innate::Helper::Link
- Innate::Helper::Redirect
- Innate::Helper::Render
- Innate::HelperAccess
- Innate::HelpersHelper
- Innate::LRUHash
- Innate::LogHub
- Innate::Mock
- Innate::Mock::Session
- Innate::Node
- Innate::Optioned
- Innate::Optioned::SingletonMethods
- Innate::Options
- Innate::Request
- Innate::Response
- Innate::Rewrite
- Innate::Route
- Innate::Session
- Innate::Session::Flash
- Innate::SingletonMethods
- Innate::StateAccessor
- Innate::Traited
- Innate::Trinity
- Innate::URLMap
- Innate::View
- Innate::View::ERB
- Innate::View::Etanni
- Innate::View::None
- Logger
- Logger::ColorFormatter
- Object

No matching classes.

# Innate::Current

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.

### Public Class Methods

new(app, *rest) click to toggle source

    # File lib/innate/current.rb, line 11
    def initialize(app, *rest)
      if rest.empty?
        @app = app
      else
        @app = Rack::Cascade.new([app, *rest])
      end
    end

### Public Instance Methods

call(env) click to toggle source

Run setup and call the app

    # File lib/innate/current.rb, line 20
    def call(env)
      setup(env)
      @app.call(env)
    end

setup(env, request = Request, response = Response, session = Session) click to toggle source

Setup new Request/Response/Session for this request/response cycle. The parameters are here to allow Ramaze to inject its own classes.

    # File 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

[Validate]

Generated with the Darkfish Rdoc Generator 2.