C
Chirag Mistry
Hi
I want to get a list of modules which are included directly in the class
in ruby. Example: Suppose below are two modules and a class defined in
ruby script.
-------------------
module M1
…
end
module M2
…
end
class MyClass
include M1
include M2
…
end
-------------------
How can I get list of modules which are included directly in the class?
Here in above example, M1 and M2 are only included in class MyClass so I
only want a list which contains modules M1 and M2 for MyClass. If we
call “MyClass.ancestors†which returns all the modules which are include
directly or indirectly in this class and all parent class hierarchy that
exactly I don’t want to get.
Regards
Chirag
I want to get a list of modules which are included directly in the class
in ruby. Example: Suppose below are two modules and a class defined in
ruby script.
-------------------
module M1
…
end
module M2
…
end
class MyClass
include M1
include M2
…
end
-------------------
How can I get list of modules which are included directly in the class?
Here in above example, M1 and M2 are only included in class MyClass so I
only want a list which contains modules M1 and M2 for MyClass. If we
call “MyClass.ancestors†which returns all the modules which are include
directly or indirectly in this class and all parent class hierarchy that
exactly I don’t want to get.
Regards
Chirag