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

Fix bug #9155. Problem with delegate class. #459

Closed
wants to merge 1 commit into from

Conversation

smathieu
Copy link

Problem was that a simple class like:

class X < DelegateClass(Integer)
  def initialize(value)
    value = Integer(value)
    super(value)
  end
end

would fail because Integer would call method_missing of SimpleDelegate, but that would raise an exception since the object to delegate to is not yet set (it will be when super is called).

/cc @nobu

@marcandre
Copy link
Member

What exactly is the issue? The given code works without the patch, no?

@smathieu
Copy link
Author

Without the fix, the following exception is raised:

 1) Error:
TestDelegateClass#test_use_delegated_method_in_constuctor:
ArgumentError: not delegated
    /Users/simon/Documents/rainforest/ruby/lib/delegate.rb:384:in `__getobj__'
    /Users/simon/Documents/rainforest/ruby/lib/delegate.rb:77:in `method_missing'
    test/test_delegate.rb:174:in `initialize'
    test/test_delegate.rb:180:in `new'
    test/test_delegate.rb:180:in `test_use_delegated_method_in_constuctor'

@ukd1
Copy link

ukd1 commented Nov 29, 2013

@marcandre this only affects 2.1 preview 2 and up.

@hsbt
Copy link
Member

hsbt commented Nov 30, 2013

@ukd1
Copy link

ukd1 commented Dec 4, 2013

Nobu resolved this with changeset r43984.

@marcandre
Copy link
Member

👍

@marcandre marcandre closed this Dec 4, 2013
@hsbt
Copy link
Member

hsbt commented Dec 4, 2013

@smathieu @ukd1 Thank you for your report!

@ukd1
Copy link

ukd1 commented Dec 4, 2013

@hsbt / @marcandre no problem. The code @smathieu wrote didn't get used; is there a guide to writing these in the correct style? Should they be sent to another place except github? We'll probably end up finding more things and would like to keep helping out, but would like to understand how to better!

Russ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants