I am trying to extend a module method in a class for a mixin.
Here is my code:
module Mod_1
def bar
puts "xxx"
end
end
class Class_A
include Mod_1
def bar
super
puts "yyy"
end
end
test = Class_A.new
test.bar
The best way of doing I could think of is:
module Mod_1
def Mod_1.foo
puts "aaa"
end
end
class Class_A
include Mod_1
def foo
Mod_1.foo
puts "bbb"
end
end
test = Class_A.new
test.foo
Is there a better way I can do this?
See the below:
Returning:
This uses aliasing. I would recommend looking them up for Ruby specially for something like what you are trying to do.
Have a read of:
http://ruby.about.com/od/rubyfeatures/a/aliasing.html