From: Scott Date: 2005-08-20T00:26:15+09:00 Subject: Re: open-uri and Kernel.open Thanks for the info. Thats a cool feature of Ruby where you can redfine existing methods. Mohit Muthanna wrote: > The open-uri module simply redefines the Kernel.open method. You can > do it yourself: > > module Kernel > private > alias original_open open > > def open( blah, *blah_params, &blah_block) > ...blah > if some_condition > original_open( blah, *blah_params, &blah_block) > end > end > > module_function :open > end > > > Above, we store the original "open" method in original_open; then we > redefine open, calling the original open function if necessary. > > HTH, > Mohit. > > > On 8/19/05, Scott wrote: > > I am new ruby usrs (and loving it) and have a question. > > > > By "requiring" opne-uri into my source file I can now reference "http" > > addresses as they were local files. It seems that open-uri "hooks" > > into the Kernel.open method. > > > > I am just wondering what aspect of the ruby language allows you to do > > this. Or is there some mechanism inside of the Kernel that allows you > > to register a different protocol? > > > > thanks in advance, scott. > > > > > > > > > -- > Mohit Muthanna [mohit (at) muthanna (uhuh) com] > "There are 10 types of people. Those who understand binary, and those > who don't."