Commit 5f2a1b6
Object#inspect: instance_variables_to_inspect フック (Ruby 4.0) を追記
Ruby 4.0 から、プライベートメソッド instance_variables_to_inspect を
定義することで、既定の inspect 出力に含めるインスタンス変数を制御できる
ようになった (Feature #21219)。パスワードなどの機密情報を持つインスタンス
変数を inspect の出力から除外する用途に使える。
このフックは Kernel のプライベートメソッドで、既定の実装は nil を返す
(その場合は全インスタンス変数が表示される)。表示したいインスタンス変数名の
Symbol 配列を返すようにオーバーライドすると、その変数だけが表示される。
#@SInCE 4.0 で分岐し、inspect の項に説明と例を追記した。実機 4.0.6 で確認済み。
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 65ff2c6 commit 5f2a1b6
1 file changed
Lines changed: 21 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
916 | 916 | | |
917 | 917 | | |
918 | 918 | | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
919 | 940 | | |
920 | 941 | | |
921 | 942 | | |
| |||
0 commit comments