From: "marcandre (Marc-Andre Lafortune)" Date: 2013-01-15T11:13:27+09:00 Subject: [ruby-core:51435] [ruby-trunk - Feature #3714][Open] Add getters for Enumerator Issue #3714 has been updated by marcandre (Marc-Andre Lafortune). Status changed from Feedback to Open I can think of two use cases. I would like to backport some Ruby 2.0 features, and the lack of introspection of Enumerator makes it quite difficult. 1) In Ruby 1.9, Enumerator#each does not accept arguments. This has been fixed in 2.0, but there is no reasonable way to monkeypatch Enumerator#each in 1.9. If these getters existed, that would be easy. 2) Ruby 2.0 introduces Enumerable#size. If the getters existed, it would have been possible to backport Enumerator#size in Ruby for 1.9 without monkeypatching all methods that produce enumerators. ---------------------------------------- Feature #3714: Add getters for Enumerator https://bugs.ruby-lang.org/issues/3714#change-35419 Author: marcandre (Marc-Andre Lafortune) Status: Open Priority: Low Assignee: knu (Akinori MUSHA) Category: core Target version: next minor =begin Given an enumerator, there is no way to know what receiver, method and arguments it is based upon (although one could use Enumerator#inspect and parse it to get the method). For sake of completeness and introspection, it could be useful to have access to them. This patch adds Enumerator#receiver, #method and #arguments: http://github.com/marcandre/ruby/commit/fd4c17f7fd Note that for Enumerator created with a block like Enumerator.new{|y| y << 1 << 2}, then receiver is a Enumerator::Generator, method is :each and arguments is []. This is consistent with inspect. Thanks. =end -- http://bugs.ruby-lang.org/