Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Merged
merged 1 commit into from

2 participants

@eregon

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.

@lsegal
Owner

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 lsegal merged commit 63199dc into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/yard/server/library_version.rb
View
4 lib/yard/server/library_version.rb
@@ -162,7 +162,7 @@ def eql?(other)
def prepare!
return if yardoc_file
meth = "load_yardoc_from_#{source}"
- send(meth) if respond_to?(meth)
+ send(meth) if respond_to?(meth, true)
end
# @return [Gem::Specification] a gemspec object for a given library. Used
@@ -220,7 +220,7 @@ def source_path_for_gem
def load_source_path
meth = "source_path_for_#{source}"
- send(meth) if respond_to?(meth)
+ send(meth) if respond_to?(meth, true)
end
end
end
Something went wrong with that request. Please try again.