Skip to content

End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Module#ancestors

mod.ancestors → array

Returns a list of modules included/prepended in mod (including mod itself).

Example
module Mod
  include Math
  include Comparable
  prepend Enumerable
end

Mod.ancestors        #=> [Enumerable, Mod, Comparable, Math]
Math.ancestors       #=> [Math]
Enumerable.ancestors #=> [Enumerable]
See also #alias_method #append_features #>= #attr also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0