Is "extend self" the same as "module_function"? Is "extend self" the same as "module_function"? ruby ruby

Is "extend self" the same as "module_function"?


module_function makes the given instance methods private, then duplicates and puts them into the module's metaclass as public methods. extend self adds all instance methods to the module's singleton, leaving their visibilities unchanged.

module M  extend self  def a; end  private  def b; endendmodule N  def c; end  private  def d; end  module_function :c, :dendclass O  include M  include NendM.aM.b  # NoMethodError: private method `b' called for M:ModuleN.cN.dO.new.aO.new.b  # NoMethodError: private method `b' called for OO.new.c  # NoMethodError: private method `c' called for OO.new.d  # NoMethodError: private method `d' called for O