attr_accessor calls method_added twice for each method in 1.8

J

Jim Cain

This code:

module Mymodule
def Mymodule.append_features(klass)
super(klass)
klass.module_eval do
def self.method_added(meth)
puts "method #{name}.#{meth.to_s} added"
end
end
end
end

class Myclass
include Mymodule
attr_accessor :hello
end

outputs this in 1.8:

method Myclass.hello added
method Myclass.hello added
method Myclass.hello= added
method Myclass.hello= added

but outputs this in 1.6.8:

method Myclass.hello added
method Myclass.hello= added

Looking in eval.c, both rb_attr and rb_add_method call klass#method_added.
 

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
474,434
Messages
2,571,689
Members
48,796
Latest member
Greg L.

Latest Threads

Top