Oracle interview question

Include a module in a class, and try to access all its instance and class methods from that class.

Interview Answer

Anonymous

23 May 2019

By using self.included, we can achieve this module TestModule def instance_meth p "am inside instance_meth" end def self.included(base) def base.class_meth p "I am in class_meth" end end end class TestClass include TestModule end TestClass.new.instance_meth TestClass.class_meth #Here by using "self.included method", I am able to access 'class methods' but without using 'extend' keyword