有一个模块MyModule
:
module MyModule
extend ActiveSupport::Concern
def first_method
end
def second_method
end
included do
second_class_method
end
module ClassMethods
def first_class_method
end
def second_class_method
end
end
end
当一些类include
打开这个模块时,它将有两个方法作为实例方法(first_method
和second_method
)和两个类方法(first_class_method
和second_class_method
)公开——这很清楚.
据说
included
块将在
这到底是什么意思?也就是说,这个方法(second_class_method
)具体什么时候执行?