public Method

Module.include?(p1)

mod.include?(module)     true or false

Returns true if module is included in mod or one of mod’s ancestors.

module A
end
class B
  include A
end
class C < B
end
B.include?(A)   #=> true
C.include?(A)   #=> true
A.include?(A)   #=> false

Source Code

/*
*  call-seq:
*     mod.include?(module)    => true or false
*  
*  Returns <code>true</code> if <i>module</i> is included in
*  <i>mod</i> or one of <i>mod</i>'s ancestors.
*     
*     module A
*     end
*     class B
*       include A
*     end
*     class C < B
*     end
*     B.include?(A)   #=> true
*     C.include?(A)   #=> true
*     A.include?(A)   #=> false
*/

VALUE
rb_mod_include_p(mod, mod2)
   VALUE mod;
   VALUE mod2;
{
   VALUE p;

   Check_Type(mod2, T_MODULE);
   for (p = RCLASS(mod)->super; p; p = RCLASS(p)->super) {
if (BUILTIN_TYPE(p) == T_ICLASS) {
    if (RBASIC(p)->klass == mod2) return Qtrue;
}
   }
   return Qfalse;
}
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.