Topic: include/extend in modules
Let's say an application contains a class called RestController. And this is inherited by each of the controllers (e.g. BookController > RestController), where RestController in turn inherits from ApplicationController. Now let's say RestController uses the include keyword to include modules (e.g. include RestControllerBase include RestControllerActions). Since a module could invoke methods defined not in the module itself but in the class that it will be mixed with, using the include and extend methods, we mix in the methods implemented in the restcontrollerbase and restcontrolleractions modules with the RestController class.
Now my question. I read that "Essentially, when you “include” a module in a class, the objects created by that class have all the methods of that module (instance methods). When you use “extend” instead, the methods apply to the class (class methods)."
So when I think of class method, I think of a method called directly on the class, so if we have class Book, then a class method of read would be called like this: Book.read.
So here is a real-world working example, where the method resource_model refers to the model associated with the current controller being invoked. My question is how do the methods defined below actually work as class methods:
@resource_model = Kernel.const_get resource_model_name
resource_model_name = self.name.gsub("Controller", "").singularize
@resource_model ||= resource_model_from_controller_name
Thanks for any response.