Referring to previously overridden method without subclass

  • Thread starter Oliver Saunders
  • Start date
O

Oliver Saunders

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?
 
J

Jano Svitok

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 :eek:ld_exec, :exec
def exec(*args)
puts "exec: #{args}"
- super *args
+ old_exec(*args)
 
M

Michael Neumann

Oliver said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,781
Messages
2,569,615
Members
45,298
Latest member
ZenLeafCBDSupplement

Latest Threads

Top