write(@stocks_list.to_xml)
end
end
end
The StocksListHandler class inherits from Mongrel::HttpHandler, so you need to
define only two methods. The rest of the functionality relating to the web server is handled
by Mongrel. The first, initialize, is a constructor used to set your @stocks_list
instance variable. Note the call to super, which calls the Mongrel::HttpHandler??™s initialize
method so that it can do any Mongrel-specific initialization. The call to super has empty
parentheses after it. In this case, because no arguments are specified, super calls the
overridden constructor with the original arguments. Because Mongrel::HttpHandler??™s
CHAPTER 9 n INVESTMENT TRACKING WITH FIDELITY 178
constructor takes no arguments, it will raise an error if you do not explicitly indicate to
super that you do not wish to pass your arguments to Mongrel::HttpHandler??™s constructor.
The second method defined in StocksListHandler is process, which handles a request
from a web browser or other HTTP client, such as the stock ticker you will create next
(Listing 9-2).
Pages:
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258