I want to find what modules were included into a specific class, excluding its ancestors. E.g.:
module M; end
module N; end
class A; include M; end
class B < A; include N; end
p B.included_modules
#=> [N, M, Kernel]
# I want only N
I can’t use B.included_modules[0] since I don’t know how many modules B includes.
If you know A is the superclass of B then
p B.included_modules - A.included_modulesshould give you what you are looking for elsep B.included_modules - B.superclass.included_modules