Eric Hodel
12/3/2004 7:02:00 PM
On 03 Dec 2004, at 10:08, Graham Jenkins wrote:
> 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.
Make a wrapper:
class Session
def self.environment
Database.use do |dbh|
Request.use do |req|
Session.use do |ses|
yield dbh, req, ses
end
end
end
end
end
Session.environment do |dbh, req, ses|
end