Inheriting Class And Instance Methods From Module To Class In Ruby
Join the DZone community and get the full member experience.Join For Free
Here you can see how to define both instance and class method in a module in order to mix them into a class
module MyModule def my_instance_method ... end def self.included klass def klass.my_class_method ... end end endAnd usage:
class MyClass include MyModule my_class_method ... def method_that_uses_the_module my_instance_method ... end end
Opinions expressed by DZone contributors are their own.