require 'caulfield/middleware'

module Caulfield
  class << self
    delegate :reset, :request, :env, 
      :status, :headers, :body,
      :session, :cookies, :set_session, :set_cookies,
      :to => 'Caulfield::Middleware.instance'
  end
end

ActiveSupport.on_load(:before_initialize) do
  Rails.configuration.middleware.use Caulfield::Middleware
end

require 'caulfield/middleware'

module Caulfield
  class << self
    delegate :reset, :request, :env, 
      :status, :headers, :body,
      :session, :cookies, :set_session, :set_cookies,
      :to => 'Caulfield::Middleware.instance'
  end
end

if defined?(Rails) && Rails.version >= '3.0.0.beta4'
  ActiveSupport.on_load :before_initialize do
    Rails.configuration.middleware.use Caulfield::Middleware
  end
end

Check if Rails is being used and the right version before inserting the middleware.
Check if Rails is being used and the right version before inserting the middleware.
