[#66126] Creation/Conversion methods/functions table for Ruby types — SASADA Koichi <ko1@...>
Hi,
5 messages
2014/11/07
[#66248] [ruby-trunk - Feature #10423] [PATCH] opt_str_lit*: avoid literal string allocations — normalperson@...
Issue #10423 has been updated by Eric Wong.
3 messages
2014/11/13
[#66595] [ruby-trunk - Bug #10557] [Open] Block not given when the argument is a string — bartosz@...
Issue #10557 has been reported by Bartosz Kopinski.
3 messages
2014/11/30
[ruby-core:66147] [ruby-trunk - Feature #4978] [Rejected] forwardable: support for 'delegate :method => :accessor'
From:
eregontp@...
Date:
2014-11-08 20:48:58 UTC
List:
ruby-core #66147
Issue #4978 has been updated by Benoit Daloze.
Status changed from Assigned to Rejected
No discussion and the current code works fine while the new one has unlikely but possible compatibility issues.
Therefore I close it.
----------------------------------------
Feature #4978: forwardable: support for 'delegate :method => :accessor'
https://bugs.ruby-lang.org/issues/4978#change-49850
* Author: Benoit Daloze
* Status: Rejected
* Priority: Normal
* Assignee: Keiju Ishitsuka
* Category: lib
* Target version: next minor
----------------------------------------
Hello,
A few months ago, I met a bug with lib/forwardable.rb:
delegate :method => :accessor
would not work, although mentioned in the documentation.
Keiju solved this at r31507, being faster than me :)
However, I would still like to propose my solution.
#instance_delegate and #single_delegate both accept
a Symbol-Symbol pair (:method => :accessor)
and a Array-Symbol pair ([:method1, :method2] => :accessor).
The current code looks like:
methods = [methods] unless methods.respond_to?(:each)
methods.each{ |method|
def_instance_delegator(accessor, method)
}
I propose:
Array(methods).each{ |method|
def_instance_delegator(accessor, method)
}
I believe this is a good use for Kernel#Array, and it does not depend on #each being defined on Symbol/String.
While I am at it, I would like to advise to not use the fact String#each for a single line String used to yield the whole String.
This is likely not what #each is intended for, and broke with 1.9, which undefined String#each.
I began to write a few tests for forwardable, is it better to add them in test/ or RubySpec ?
---Files--------------------------------
0001-lib-forwardable-Forwardable-instance_delegate-Single.patch (1.16 KB)
--
https://bugs.ruby-lang.org/