attr_accessor calls method_added twice for each method in 1.8

Discussion in 'Ruby' started by Jim Cain, Jul 18, 2003.

  1. Jim Cain

    Jim Cain Guest

    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.
     
    Jim Cain, Jul 18, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. andy6
    Replies:
    2
    Views:
    762
    andy6 via DotNetMonster.com
    Jun 9, 2006
  2. Caio Chassot

    method_added for class methods

    Caio Chassot, Sep 9, 2005, in forum: Ruby
    Replies:
    9
    Views:
    132
    Caio Chassot
    Sep 10, 2005
  3. robertj
    Replies:
    2
    Views:
    80
    Trans
    Dec 12, 2005
  4. Keith Rarick

    method_added hook and class methods

    Keith Rarick, Aug 3, 2007, in forum: Ruby
    Replies:
    4
    Views:
    130
    Robert Dober
    Aug 4, 2007
  5. Trans
    Replies:
    7
    Views:
    135
    Trans
    Nov 14, 2007
Loading...

Share This Page