lib/cuba.rb in cuba-3.0.1.rc2 vs lib/cuba.rb in cuba-3.1.0.rc1
- old
+ new
@@ -82,14 +82,21 @@
def self.settings
@settings ||= {}
end
+ def self.deepclone(obj)
+ Marshal.load(Marshal.dump(obj))
+ end
+
def self.inherited(child)
- child.settings.replace(settings)
+ child.settings.replace(deepclone(settings))
end
+ attr :env
+ attr :req
+ attr :res
attr :captures
def initialize(&blk)
@blk = blk
@captures = []
@@ -101,25 +108,13 @@
def call(env)
dup.call!(env)
end
- def req
- Thread.current[:_cuba_req]
- end
-
- def res
- Thread.current[:_cuba_res]
- end
-
- def env
- Thread.current[:_cuba_env]
- end
-
def call!(env)
- Thread.current[:_cuba_env] = env
- Thread.current[:_cuba_req] = Rack::Request.new(env)
- Thread.current[:_cuba_res] = Cuba::Response.new
+ @env = env
+ @req = Rack::Request.new(env)
+ @res = Cuba::Response.new
# This `catch` statement will either receive a
# rack response tuple via a `halt`, or will
# fall back to issuing a 404.
#