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
filters and handlers need recursive processing via a resource method
automatthew (author)
Sat Oct 04 01:23:28 -0700 2008
commit  35aec621a19c6d4b2250919ef9707bb69336cd8d
tree    1daa5b8a56429fe1292cbbbe57dd0ee173d4e533
parent  756c237f041676186d43f89dcab43fd24992c53d
...
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
 
51
52
53
...
34
35
36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
38
39
40
0
@@ -34,20 +34,7 @@ module Waves
0
         request.response.content_type = request.accept.default
0
         # grab the appropriate resource from those declared in the configuration, based on the request
0
         resource = Waves.config.resource.new( request )
0
- begin
0
- # invoke the request method, wrapped by the before and after methods
0
- resource.before
0
- body = resource.send( request.method )
0
- request.response.write( body ) if body.respond_to?( :to_s )
0
- resource.after
0
- rescue Exception => e
0
- # handle any exceptions using the resource handlers, if any
0
- Waves::Logger.info e.to_s
0
- ( request.response.body = resource.handler( e ) ) rescue raise e
0
- ensure
0
- # no matter what happens, also run the resource's always method
0
- resource.always
0
- end
0
+ resource.process
0
         # okay, we've handled the request, now write the response unless it was already done
0
         request.response.finish
0
       end
...
73
74
75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
77
78
...
80
81
82
83
84
 
 
 
85
86
87
...
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
...
98
99
100
 
 
101
102
103
104
105
106
0
@@ -73,6 +73,24 @@ module Waves
0
       
0
       # Resources are initialized with a Waves::Request
0
       def initialize( request ); @request = request ; end
0
+
0
+ def process
0
+ begin
0
+ # invoke the request method, wrapped by the before and after methods
0
+ before
0
+ body = send( request.method )
0
+ request.response.write( body ) if body.respond_to?( :to_s )
0
+ after
0
+ rescue Exception => e
0
+ # handle any exceptions using the resource handlers, if any
0
+ Waves::Logger.info e.to_s
0
+ ( request.response.body = handler( e ) ) rescue raise e
0
+ ensure
0
+ # no matter what happens, also run the resource's always method
0
+ always
0
+ end
0
+ end
0
+
0
       def to( resource )
0
         resource = case resource
0
         when Base
0
@@ -80,8 +98,9 @@ module Waves
0
         when Symbol, String
0
           Waves.main::Resources[ resource ]
0
         end
0
- traits.waves.resource = resource.new( request )
0
- traits.waves.resource.send( request.method )
0
+ r = traits.waves.resource = resource.new( request )
0
+ r.process
0
+ nil
0
       end
0
       def redirect( path ) ; request.redirect( path ) ; end
0
       def render( path, assigns = {} ) ; Waves::Views::Base.process( request ) { render( path, assigns ) }; end

Comments

    No one has commented yet.