[pbrannan@zaphod testsing]$ cat testsing.c
#include <ruby.h>
VALUE foo(VALUE self)
{
return Qnil;
}
void Init_testsing()
{
VALUE rb_mFoo = rb_const_get(rb_cObject, rb_intern(“Foo”));
rb_define_singleton_method(rb_mFoo, “foo”, foo, 0);
}
[pbrannan@zaphod testsing]$ cat testsing.rb
module Foo
def self.singleton_method_added(id)
p id
end
end
require ‘testsing.so’
module Foo
def self.bar
end
end
[pbrannan@zaphod testsing]$ ruby testsing.rb
:singleton_method_added
:bar
[pbrannan@zaphod testsing]$ ruby -v
ruby 1.6.8 (2002-12-24) [i686-linux]
[pbrannan@zaphod testsing]$ ruby-1.7 testsing.rb
:singleton_method_added
:bar
[pbrannan@zaphod testsing]$ ruby-1.7 -v
ruby 1.8.0 (2003-05-01) [i686-linux]