How do I override methods in a module?
+1
A:
Just put your new method in later on in the code. For example, if this is the module (somefile.rb):
module M
def some_method
# ...
end
def get_time
time = Time.new
return time
end
end
Put this in the file that needs the module:
require "some_module"
module M
def get_time
time = Time.parse("07/09/10 21:22")
return time
end
end
Adrian
2010-07-12 16:34:12
will this work for overriding method in a class?
Mo
2010-07-13 11:27:30
@Mo: Yes. And this extra sentence is to pad the comment with content so stack overflow doesn't get mad about a short comment.
Adrian
2010-07-13 16:35:14