lib/ruby_app/request.rb in RubyApp-0.5.40 vs lib/ruby_app/request.rb in RubyApp-0.5.41

- old
+ new

@@ -26,29 +26,35 @@ def self.get Thread.current[:_request] end + def self.exists? + return Thread.current[:_request] + end + def self.create!(environment = RubyApp::Application.environment) Thread.current[:_request] = RubyApp::Request.new(environment) end def self.destroy! Thread.current[:_request] = nil end def self.create_context! - RubyApp::Request.create! - RubyApp::Response.create! - RubyApp::Language.load! - RubyApp::Session.load! - begin - yield - ensure - RubyApp::Session.unload! - RubyApp::Language.unload! - RubyApp::Response.destroy! - RubyApp::Request.destroy! + unless RubyApp::Request.exists? + RubyApp::Request.create! + RubyApp::Response.create! + RubyApp::Language.load! + RubyApp::Session.load! + begin + yield + ensure + RubyApp::Session.unload! + RubyApp::Language.unload! + RubyApp::Response.destroy! + RubyApp::Request.destroy! + end end end private