You can either use
extend to mix in a module’s functionality into a class. The difference is this:
includemakes the module’s methods available to the instance of a class, while
extendmakes these methods available to the class itself.
Check out this example:
module Greetings def say_hello puts "Hello!" end end class Human include Greetings end Human.new.say_hello # => "Hello!" Human.say_hello # NoMethodError class Robot extend Greetings end Robot.new.say_hello # NoMethodError Robot.say_hello # => "Hello!"
If you want more information on
extend, I recommend the following resources:
You can use HTML tags for formatting. Wrap code in <code> tags and multiple lines of code in <pre><code> tags.