From 9f354b938569133901bca62dc05fc8581edb6f89 Mon Sep 17 00:00:00 2001 From: Lee Jarvis Date: Sun, 24 Apr 2011 19:29:01 +0100 Subject: [PATCH] simplify some methods relying on implicit functionality --- lib/pry/pry_instance.rb | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/lib/pry/pry_instance.rb b/lib/pry/pry_instance.rb index a6e57949c..5d3b315ee 100644 --- a/lib/pry/pry_instance.rb +++ b/lib/pry/pry_instance.rb @@ -54,12 +54,7 @@ def nesting=(v) # @return [Pry] The parent of the current Pry session. def parent idx = Pry.sessions.index(self) - - if idx > 0 - Pry.sessions[idx - 1] - else - nil - end + Pry.sessions[idx - 1] if idx > 0 end # Execute the hook `hook_name`, if it is defined. @@ -125,12 +120,7 @@ def repl(target=TOPLEVEL_BINDING) end return_value = repl_epilogue(target, nesting_level, break_data) - - # if one was provided, return the return value - return return_value if return_value - - # otherwise return the target_self - target_self + return_value || target_self end # Perform a read-eval-print. @@ -356,10 +346,9 @@ def valid_expression?(code) # valid_expression?("class Hello; end") #=> true def valid_expression?(code) RubyParser.new.parse(code) + true rescue Racc::ParseError, SyntaxError false - else - true end end end