GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Rubygem
Description: Resource-oriented open source Ruby framework for Web apps.
Homepage: http://rubywaves.com/
Clone URL: git://github.com/dyoder/waves.git
fixed constraints to use new Accepts thingies
automatthew (author)
Tue Jul 22 08:27:23 -0700 2008
commit  df5834a132827e2c3176686d47c2ab2f88c394e3
tree    bca754d7c0932f4bd2fbc54f324f8db2143275e0
parent  159026797e2478a2e5dd04d3a0951e91c2476709
...
16
17
18
19
 
 
20
21
22
...
16
17
18
 
19
20
21
22
23
0
@@ -16,7 +16,8 @@ module Waves
0
         METHODS.all? do | method |
0
           wanted = instance_variable_get( "@#{method}")
0
           got = request.send( method ) if wanted
0
- wanted === got
0
+ # wanted === got
0
+ wanted.is_a?( Proc) ? wanted.call( got ) : got === wanted
0
         end
0
       end
0
             
...
23
24
25
26
 
 
 
 
 
 
 
 
 
 
 
 
27
28
29
...
23
24
25
 
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
0
@@ -23,7 +23,18 @@ describe "A mapping" do
0
   end
0
   
0
   it "can match the Accepts header" do
0
- mapping.action( :accepts => 'text/plain' ) { "boooring."}
0
+ mapping.action( :accept => 'text/plain' ) { "boooring."}
0
+
0
+ request.get("/foo", 'HTTP_ACCEPT' => 'text/plain').status.should == 200
0
+ request.get("/foo", 'HTTP_ACCEPT' => 'text/xml').status.should == 404
0
+ end
0
+
0
+ it "can use a lambda on any of the above" do
0
+ mapping.action( :accept => lambda { |types| types.include? 'text/plain' } ) { "boooring."}
0
+ mapping.action( :accept => lambda { |types| types.include? /image/ } ) { "cool."}
0
+
0
+ request.get("/foo", 'HTTP_ACCEPT' => 'text/plain').status.should == 200
0
+ request.get("/foo", 'HTTP_ACCEPT' => 'image/jpeg').status.should == 200
0
     request.get("/foo", 'HTTP_ACCEPT' => 'text/xml').status.should == 404
0
   end
0
   

Comments

    No one has commented yet.