Move should_print? check into show_result

This commit is contained in:
Ryan Fitzgerald 2012-08-07 21:03:36 -07:00
parent 331f47b0cf
commit 9d5ae76fd4
1 changed files with 6 additions and 5 deletions

View File

@ -249,7 +249,7 @@ class Pry
target = Pry.binding_for(target)
result = re(target)
show_result(result) if should_print?
show_result(result)
end
# Perform a read-eval
@ -327,8 +327,10 @@ class Pry
def show_result(result)
if last_result_is_exception?
exception_handler.call(output, result, self)
else
elsif should_print?
print.call(output, result)
else
# nothin'
end
rescue RescuableException => e
# Being uber-paranoid here, given that this exception arose because we couldn't
@ -614,11 +616,10 @@ class Pry
end
# Whether the print proc should be invoked.
# Currently only invoked if the output is not suppressed OR the last result
# is an exception regardless of suppression.
# Currently only invoked if the output is not suppressed.
# @return [Boolean] Whether the print proc should be invoked.
def should_print?
!@suppress_output || last_result_is_exception?
!@suppress_output
end
# Returns the appropriate prompt to use.