[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Referring to previously overridden method without subclass

Oliver Saunders

4/1/2008 1:03:00 PM

I'm trying to debug a bit of code. I want to output all the parameters
passed to PGconn#exec each time it is called but still have the method
function as it should.


I tried this:


class PGconn
def exec(*args)
puts "exec: #{args}"
super *args
end
end

But super ends up calling Kernel#exec, how can I refer to the version of
exec before I added the puts enhancement?
--
Posted via http://www.ruby-....

3 Answers

Jano Svitok

4/1/2008 1:07:00 PM

0

On Tue, Apr 1, 2008 at 3:02 PM, Oliver Saunders
<oliver.saunders@gmail.com> wrote:
> I'm trying to debug a bit of code. I want to output all the parameters
> passed to PGconn#exec each time it is called but still have the method
> function as it should.
>
>
> I tried this:
>
>
> class PGconn
+ alias_method :old_exec, :exec
> def exec(*args)
> puts "exec: #{args}"
- super *args
+ old_exec(*args)
> end
> end

Michael Neumann

4/1/2008 1:10:00 PM

0

Oliver Saunders wrote:
> I'm trying to debug a bit of code. I want to output all the parameters
> passed to PGconn#exec each time it is called but still have the method
> function as it should.
>
>
> I tried this:
>
>
> class PGconn

alias old_exec exec

> def exec(*args)
> puts "exec: #{args}"

old_exec(*args)

> end
> end

Regards,

Michael


Oliver Saunders

4/1/2008 1:37:00 PM

0

Thanks.
--
Posted via http://www.ruby-....