ts1
(ts)
21
----------------------------------------> 8---- before.rb
try this
module Mod
before :fnname
def fnname_Mod
puts "fnname_Mod called"
end
end
class Klass
include Mod
def fnname
puts "fnname called"
end
end
k=Klass.new
k.fnname
class A < Klass
def fnname
puts "A#fnname called"
super
end
end
A.new.fnname
Guy Decoux
class A < Klass
def fnname
puts “A#fnname called”
super
end
end
A.new.fnname
Ok, another version from the heart method
‘beforehack_insertBeforeWrapper’:
def beforehack_insertBeforeWrapper(klass,method_name)
debug "beforehack_insertBeforeWrapper: hacking
#{klass}.#{method_name} to exec #{method_name}#{self}", :before
klass.module_eval <<-END_OF_ADVICE
@before_in_beforehack_semaphore=true
alias pre_include#{self}#{klass}#{method_name} #{method_name}
def #{method_name}(*args,&block)
debug “redefined #{klass}.#{method_name} - calling
‘#{method_name}#{self}', then
'pre_include#{self}#{klass}#{method_name}’”, :before
#{method_name}#{self}(*args,&block)
pre_include#{self}#{klass}#{method_name}(*args,&block)
end
@before_in_beforehack_semaphore=false
END_OF_ADVICE
end
It now calls the wrapper method twice in the case above, but it can
be easily detected in the wrapper method, and it is enough for me.
Anyway, you have a modified ruby, so just keep silent… :)))
Really, thanks for pointing out this bug! 
Circum
PS: since I use ruby, where everything is soooo simple and
straightforward and elagant, I have scratched too many hair from
my head… :))
ts1
(ts)
23
def beforehack_insertBeforeWrapper(klass,method_name)
more complex, now 
module Mod
undef :fnname_Mod
end
A.new.fnname
I just want to remove the before advice and still want that #fnname work
Guy Decoux
ts wrote:
def beforehack_insertBeforeWrapper(klass,method_name)
more complex, now 
module Mod
undef :fnname_Mod
end
A.new.fnname
I just want to remove the before advice and still want that #fnname work
Guy Decoux
module Mod
def fnname_Mod
end
end
:)))
Ferenc