我需要 mixin 一个模块,但是模块中的一些函数成为类函数,一些函数成为实例方法. 请问如何做到
Ruby Pattern: Extend through Include
http://www.dan-manges.com/blog/27
#1 楼 @Rei 感谢
module Module module ClassMethods end module InstanceMethods end def self.included(receiver) receiver.extend ClassMethods receiver.send :include, InstanceMethods end end