From: Shin-ichiro HARA Date: 2002-08-08T19:07:08+09:00 Subject: [ruby-list:35728] Re: import-module (Re: Re: scope-in-state) 原です。 import-module の Ver.0.18 で実験的に super でオリジナルの メソッドを呼び出す(ように見える)ようにしてみました。 require "import-module" class Foo include Enumerable def each yield 10 yield 20 yield 30 end end module IndexedEach def each(&b) i = 0 super do |x| i += 1 yield(i, x) end end end foo = Foo.new Foo.import_module(IndexedEach) do p foo.to_a #=> [[1, 10], [2, 20], [3, 30]] end 便利な気もするし、悪ノリのような気もするし、どうですかね。