Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

When given Symbol names, {Single}Forwardable#def_delegators should reject #__id__ and #__send__ as String names. #385

Closed
wants to merge 1 commit into
from

Conversation

2 participants
Member

kachick commented Aug 27, 2013

I couldn't find test_forwardable.rb.

ruby -v ruby 2.1.0dev (2013-08-27 trunk 42710) [x86_64-linux]

# coding: us-ascii

$VERBOSE = true

require 'forwardable'

class Foo
  extend Forwardable

  attr_reader :destination

  def initialize
    @destination = []
  end

  def_delegators :@destination, '__id__'
end

foo = Foo.new

p foo.destination.__id__.equal?(foo.__id__) #=> false

class Foo
  def_delegators :@destination, :__id__
end

p foo.destination.__id__.equal?(foo.__id__) #=> true


DESTINATION = []
obj = Object.new
obj.extend SingleForwardable

obj.def_delegators :DESTINATION, '__id__'
p obj.__id__.equal?(DESTINATION.__id__) #=> false

obj.def_delegators :DESTINATION, :__id__
p obj.__id__.equal?(DESTINATION.__id__) #=> true
@kachick kachick forwardable.rb: adjust to symbol names
* lib/forwardable.rb (Forwardable#def_delegators,
  Forwardable#def_instance_delegators
  SingleForwardable#def_delegators,
  SingleForwardable#def_single_delegators): When given Symbol names,
  reject #__id__ and #__send__ as String names. To coerce with #to_s
  is better than #to_str or #to_sym for %{} in #def_delegator.
c6c5bb3
Member

zzak commented Sep 3, 2013

@kachick The maintainer of forwardable should give you some feedback, that is keiju-san. Unfortunately he doesn't monitor github, so I suggest opening a ticket on bugs.ruby-lang.org and assigning it to him.

Member

kachick commented Sep 3, 2013

@zzak Thanks for your suggestion :)
I have opened the ticket http://bugs.ruby-lang.org/issues/8855.

/cc @keiju

Member

zzak commented Oct 15, 2013

Closing in favor of redmine ticket Bug #8855

@zzak zzak closed this Oct 15, 2013

@kachick kachick deleted the kachick:forwardable-special_methods_via_symbol branch Oct 15, 2013

@kachick kachick restored the kachick:forwardable-special_methods_via_symbol branch Oct 15, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment