From 3be2a50789f1b9ed09013f874e0f3d1f20410a06 Mon Sep 17 00:00:00 2001 From: Magnus Holm Date: Mon, 30 Nov 2009 13:02:23 +0100 Subject: [PATCH] Camping.use now also accepts a block --- lib/camping-unabridged.rb | 4 ++-- lib/camping.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/camping-unabridged.rb b/lib/camping-unabridged.rb index 999c726..9c9da3d 100644 --- a/lib/camping-unabridged.rb +++ b/lib/camping-unabridged.rb @@ -621,8 +621,8 @@ def method_missing(m, c, *a) # use Rack::MethodOverride # use Rack::Session::Memcache, :key => "session" # end - def use(*a) - m = a.shift.new(method(:call), *a) + def use(*a, &b) + m = a.shift.new(method(:call), *a, &b) meta_def(:call) { |e| m.call(e) } end end diff --git a/lib/camping.rb b/lib/camping.rb index 8e64d7a..bc637d4 100644 --- a/lib/camping.rb +++ b/lib/camping.rb @@ -46,6 +46,6 @@ def M;def M;end;constants.map{|c|k=const_get(c) def method_missing m,c,*a;X.M;h=Hash===a[-1]?a.pop: {} e=H[Rack::MockRequest.env_for('',h[:env]||{})] k=X.const_get(c).new(e,m.to_s);k.send("input=",h[:input])if h[:input] -k.service(*a);end;def use*a;m=a.shift.new(method(:call),*a);meta_def(:call){|e| +k.service(*a);end;def use*a,&b;m=a.shift.new(method(:call),*a,&b);meta_def(:call){|e| m.call(e)}end end;module Views;include X,Helpers end;module Models autoload:Base,'camping/ar';def Y;self;end end;autoload:Mab,'camping/mab';C end