On 7/14/06, ara.t.howard / noaa.gov <ara.t.howard / noaa.gov> wrote:
> On Fri, 14 Jul 2006 transfire / gmail.com wrote:
>
> >  (class << File; self; end).instance_eval {
> >    define_method(:open,&open_m)
>                                   and the block?
>
> -a
> --
> suffering increases your inner strength.  also, the wishing for suffering
> makes the suffering disappear.
> - h.h. the 14th dali lama
>
I had to cheat ;)

File::OPEN_M = open_m
class File
  eval "
def self.open(*args, &block)
    OPEN_M.call(*args, &block)
end
"
end

The problem is - as I'm sure you know - that define_method doesn't
honour the block argument of the method reference. I'd be very
interested to see if you can do it cleanly in ruby 1.8.

Regards,
Sean