Ruby: module, require i include
Próbuję użyć modułów Ruby (mixinów).
Mam test.rb:
#!/usr/bin/env ruby
require_relative 'lib/mymodule'
class MyApp
include MyModule
self.hallo
end
i lib / mymodule.rb:
module MyModule
def hallo
puts "hallo"
end
end
Dość prosta konfiguracja. Ale to nie działa :( :
ruby test.rb
test.rb:8:in `<class:MyApp>': undefined method `hallo' for MyApp:Class (NoMethodError)
from test.rb:6:in `<main>'
Gdzie jest mój błąd?