こんにちは、hachi8833です。先日の記事「[Rails5] Active Support Core ExtensionsのStringクラス(2)html_safe」を書いていて見つけた、module_functionの使い方を別記事にいたしました。 条件 Rubyバージョン: 3.2.0 Railsバージョン: 7.0.2のActive Support モジュールでのメソッド定義とmodule_function Active SupportのERBクラスを見てみると、Utilモジュールが定義されており、Ruby標準のERBライブラリをオーバーライドします。 ERBクラスはざっくり以下のような構成になっています。 # ERBクラスの構成 class ERB module Util def メソッド1 ... end module_function :メソッド1 def メソッド2 .