moduleModdefhello"Hello from Mod.\n"endendclassKlassdefhello"Hello from Klass.\n"endendk =Klass.newk.hello #=> "Hello from Klass.\n"k.extend(Mod) #=> #<Klass:0x401b3bc8>k.hello #=> "Hello from Mod.\n"
ActiveSupport::Cache 里就用这种方式给 Store 实例对象添加了 Local Cache 相关方法。