From f9dd759b715d3a33d2d291503530e7aaf91feab0 Mon Sep 17 00:00:00 2001 From: Marek Skrobacki Date: Mon, 5 Feb 2018 19:31:58 +0000 Subject: [PATCH] add Response#pretty_print As discussed in #567, the changes introduced 5a78a14 resulted in change of behavior when viewing the Response objects using command line version of the HTTParty or tools like pry. This commits adds minimal version of the #pretty_print method that behaves the same as code before, when response was inheriting from BasicObject rather than Object. This is because PP::ObjectMixin applies to Object, but it not BasicObject. --- lib/httparty/response.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/httparty/response.rb b/lib/httparty/response.rb index e31a59f6..3d32772d 100644 --- a/lib/httparty/response.rb +++ b/lib/httparty/response.rb @@ -67,6 +67,14 @@ def to_s end end + def pretty_print(pp) + if !parsed_response.nil? && parsed_response.respond_to?(:pretty_print) + parsed_response.pretty_print(pp) + else + super + end + end + def display(port=$>) if !parsed_response.nil? && parsed_response.respond_to?(:display) parsed_response.display(port)