From: Robert Date: 2003-05-22T08:00:04+09:00 Subject: Re: How I'd like method-wrapping to work... This is a multi-part message in MIME format. ------=_NextPart_000_000B_01C31FFA.C6FBC660 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Oops, forgot to attach the other test. robert ------=_NextPart_000_000B_01C31FFA.C6FBC660 Content-Type: application/octet-stream; name="another_test.rb" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="another_test.rb" require 'hooks.rb' class Foo attr :len, true def initialize; @len = 0; end def bar puts "bar: #{self.len}" "bar!" end define_hook :bar do puts "hook 1: #{this.len}" this.len += 1 prior end define_hook :bar do puts "hook 2: #{this.len}" this.len += 1 puts "prior 1" prior puts "prior 2" prior "gotcha!" end def foo(x) p this puts "foo #{x}" Foo.new.foo nil if x "foo!" end define_hook :foo do |x| puts "hook foo 1: #{this.len}" puts "hook foo 1: x=#{x}" this.len += 1 prior end end f = Foo.new ["__hook__bar_0", "__hook__bar_1", "bar"].each do |m| puts "calling #{m}" p f.send m puts "" end p f.foo("xxx") ------=_NextPart_000_000B_01C31FFA.C6FBC660--