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#prepended

prepended(othermod)

The equivalent of included, but for prepended modules.

Example
module A
  def self.prepended(mod)
    puts "#{self} prepended to #{mod}"
  end
end
module Enumerable
  prepend A
end
 # => prints "A prepended to Enumerable"
See also #prepend #prepend_features #name #private also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0