F
Ferenc Engard
class A < Klass
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... )
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... )