K
Kedar Mhaswade
I understand that the use of the Module's class method "module_function"
is to
- create class method copies of the instance methods defined in module
- make those instance methods "private" when mixed in.
e.g.
1 module Functions
2 module_function
3 def greet(whom)
4 puts "Hi, #{whom}"
5 end
6 end
Now, if I included this module in my class like:
class Greeter
include Functions
end
everything works as expected.
But, if I opened up the Object class and included Function there e.g.
class Object
include Functions
end
(like probably what Ruby does with Kernel module),
then I find that module_function (line #2 above) is __not__ needed!
Do I conclude that including a module in Object class has the same
effect as module_function?
Thank you,
Kedar
is to
- create class method copies of the instance methods defined in module
- make those instance methods "private" when mixed in.
e.g.
1 module Functions
2 module_function
3 def greet(whom)
4 puts "Hi, #{whom}"
5 end
6 end
Now, if I included this module in my class like:
class Greeter
include Functions
end
everything works as expected.
But, if I opened up the Object class and included Function there e.g.
class Object
include Functions
end
(like probably what Ruby does with Kernel module),
then I find that module_function (line #2 above) is __not__ needed!
Do I conclude that including a module in Object class has the same
effect as module_function?
Thank you,
Kedar