标签:
===Module#included
当一个模块混入到类时,如果该模块的included方法已经定义,那么该方法被调用。该方法的唯一参数就是接受混含的类的名字。
1 module M 2 def self.included(c) 3 puts "I have justbeen mixed into #{c}." 4 end 5 end 6 7 8 class C 9 include M 10 end
也就是说当类c中执行include M时,调用self.included方法
标签:
原文地址:http://www.cnblogs.com/timsheng/p/5178648.html