Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

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

Conversation

@kachick
Copy link
Member

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
* 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.
@zzak

This comment has been minimized.

Copy link
Member

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.

@kachick

This comment has been minimized.

Copy link
Member Author

commented Sep 3, 2013

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

/cc @keiju

@zzak

This comment has been minimized.

Copy link
Member

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
2 participants
You can’t perform that action at this time.