fix for ruby 2.0.0dev with respond_to? returning false for protected methods #574

Merged
merged 1 commit into from Aug 6, 2012

Conversation

Projects
None yet
2 participants
Contributor

eregon commented Jul 15, 2012

Hello,

With ruby trunk (2.0.0dev), Object#respond_to? responds false for protected methods.
See https://github.com/ruby/ruby/blob/051799b674580fb96b928d990045976e948f7151/NEWS#L181-182
and ruby/ruby@23473d1.

This error causes yard server to fail, because LibraryVersion#source_path is not set properly due to this.

This mean, in the case you called respond_to? on +self+ (usually without receiver), to check for a defined protected method, it will return false instead of true. They are a few other cases of respond_to? without receiver in YARD, but they seem less obvious (in all cases, they are 8 specs failing with 2.0.0dev, 6 with 1.9.2).

I'm not sure of the usage of protected there. Is there a case when another LibraryVersion wants to call one of these methods? It seems the five last methods of LibraryVersion could be private. But I don't know YARD source well.

Owner

lsegal commented Aug 6, 2012

I'm not sure of the usage of protected there. Is there a case when another LibraryVersion wants to call one of these methods? It seems the five last methods of LibraryVersion could be private. But I don't know YARD source well.

We use protected in YARD to have API connotations. Protected methods in YARD are available to be overridden through subclassing-- I'm aware this is not Ruby's technical distinction, but it works for us.

lsegal merged commit 63199dc into lsegal:master Aug 6, 2012

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