Graham Jenkins wrote: > I'm considering raising an RCR: "allow multiple ensure blocks". I've > searched for this to some extent - have I missed anything obvious? > > I want to be able to write: > > begin > raise 'something bad' > ensure > puts 1 > ensure > puts 2 > end How does this differ from: begin raise 'something bad' ensure puts 1 puts 2 end ? - Jamis > > This is so I can reliably cleanup all request resources in my fcgi > scripts (rollback database connection, finish the request, cleanup > environment and session objects) without having to nest > begin...ensure...end blocks inside the only ensure block I'm allowed > to write. > > I know that the Ruby Way is probably to nest separate blocks for each > of these resources > > Database.use { |dbh| > Request.use { |req| > Session.use { |ses| > ... > # my code here > } > } > } > > but I end up nesting the real code about 10 layers deep if I do that. > > > -- Jamis Buck jgb3 / email.byu.edu http://www.jamisbuck.org/jamis