problem with Module#append_features

F

Ferenc Engard

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... :))
 
T

ts

F> 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
 
F

Ferenc Engard

ts said:
F> 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
 

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

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top