diff --git a/error.c b/error.c index 6844f99..5e4ecd4 100644 --- a/error.c +++ b/error.c @@ -732,10 +732,16 @@ exc_equal(VALUE exc, VALUE obj) CONST_ID(id_mesg, "mesg"); if (rb_obj_class(exc) != rb_obj_class(obj)) { - ID id_message, id_backtrace; + VALUE klass; + ID id_class, id_message, id_backtrace; + CONST_ID(id_class, "class"); CONST_ID(id_message, "message"); CONST_ID(id_backtrace, "backtrace"); + klass = rb_check_funcall(obj, id_class, 0, 0); + if (klass == Qundef) return Qfalse; + if (!rb_equal(rb_obj_class(exc), klass)) + return Qfalse; mesg = rb_check_funcall(obj, id_message, 0, 0); if (mesg == Qundef) return Qfalse; backtrace = rb_check_funcall(obj, id_backtrace, 0, 0); diff --git a/lib/delegate.rb b/lib/delegate.rb index 863c63f..a0f8459 100644 --- a/lib/delegate.rb +++ b/lib/delegate.rb @@ -88,6 +88,10 @@ class Delegator < BasicObject r end + def class + __getobj__.class + end + # # Returns the methods available to this delegate object as the union # of this object's and \_\_getobj\_\_ methods.