[Ruby2]how to dynamically attach :pre :post :wrap ro methods?

Hi gurus and nubys,

Loooking forward to the syntax

def foo:pre
end

I wonder: could we add preconditions without resorting to syntax?

Would we have something like this:

myobj.methods.each do |m|
m.wrap(:pre) {|*args| p args }
end

?
Sounds obvious and necessary to me, but I can’t remeber talks about
this…

TIA

See
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/97440

Something similar can be implemented trivially using the same principle,
with Object#method instead of Module#instance_method and using the
singleton class.

···

On Wed, Jun 02, 2004 at 03:53:41AM +0900, gabriele renzi wrote:

Would we have something like this:

myobj.methods.each do |m|
m.wrap(:pre) {|*args| p args }
end

?
Sounds obvious and necessary to me, but I can’t remeber talks about
this…


Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

…Deep Hack Mode – that mysterious and frightening state of
consciousness where Mortal Users fear to tread.
– Matt Welsh