Prev | Current Page 245 | Next

David Berube

"Practical Reporting with Ruby and Rails"

) You create a symbols node, and then a symbol node for each of your symbols.
When you call a method that??™s not defined inside a call to the xml function, Remarkably
uses it as a node name, so you can use the symbols and symbol methods to create nodes
named symbols and symbol, respectively. (This approach is very similar to Markaby, and
while it appears strange at first, it rapidly becomes more familiar.) Undefined methods
are caught using Ruby??™s method_missing technique, and they are converted into XML tags.
nTip You could replace the to_xml method with a to_json or a to_s method if your application needed
the output as JSON or as a string, respectively.
The StocksListHandler class is the Mongrel handler that responds to the request for
the XML list of stocks:
class StocksListHandler < Mongrel::HttpHandler
def initialize(stocks_list)
@stocks_list = stocks_list
super()
end
def process(request, response)
response.start(200) do |headers, output_stream|
headers["Content-Type"] = "text/plain"
output_stream.


Pages:
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257
Potopek uchwyt lcd wyciągarki hotele londyn Wczasy nad morzem