Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Modernize respond_to implementations

Since at least Ruby 1.8.7, `respond_to?` has supported an optional
second parameter which causes private/protected methods to be included
in the check. This defaults to false.

As of Ruby 2, there's a warning logged if an implementation of
`respond_to` does not take a second parameter, see:
ruby/ruby@a106b31

This change updated the respond_to implementations to support the second
parameter.
  • Loading branch information...
commit 82130c8c985aec1d724c02117534521e02fa6aa9 1 parent 7c1a19e
@derekprior derekprior authored
Showing with 4 additions and 4 deletions.
  1. +2 −2 lib/httparty/response.rb
  2. +2 −2 lib/httparty/response/headers.rb
View
4 lib/httparty/response.rb
@@ -50,9 +50,9 @@ def inspect
alias_method :multiple_choice?, :multiple_choices?
end
- def respond_to?(name)
+ def respond_to?(name, include_all = false)
return true if [:request, :response, :parsed_response, :body, :headers].include?(name)
- parsed_response.respond_to?(name) || response.respond_to?(name)
+ parsed_response.respond_to?(name, include_all) || response.respond_to?(name, include_all)
end
protected
View
4 lib/httparty/response/headers.rb
@@ -23,8 +23,8 @@ def method_missing(name, *args, &block)
end
end
- def respond_to?(method)
- super || @header.respond_to?(method)
+ def respond_to?(method, include_all = false)
+ super || @header.respond_to?(method, include_all)
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.