From: Marc-Andre Lafortune <redmine@...>
Date: 2010-08-19T04:51:53+09:00
Subject: [ruby-core:31761] [Feature #3714] Add getters for Enumerator

Feature #3714: Add getters for Enumerator
http://redmine.ruby-lang.org/issues/show/3714

Author: Marc-Andre Lafortune
Status: Open, Priority: Normal
Category: core, Target version: 1.9.x

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.


----------------------------------------
http://redmine.ruby-lang.org