File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed
Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -1463,21 +1463,16 @@ def truncate_prompt_main(str) # :nodoc:
14631463 end
14641464 end
14651465
1466- def basic_object_safe_main_call ( method )
1467- main = @context . main
1468- Object === main ? main . __send__ ( method ) : Object . instance_method ( method ) . bind_call ( main )
1469- end
1470-
14711466 def format_prompt ( format , ltype , indent , line_no ) # :nodoc:
14721467 format . gsub ( /%([0-9]+)?([a-zA-Z%])/ ) do
14731468 case $2
14741469 when "N"
14751470 @context . irb_name
14761471 when "m"
1477- main_str = basic_object_safe_main_call ( :to_s ) rescue "!#{ $!. class } "
1472+ main_str = @context . safe_method_call_on_main ( :to_s ) rescue "!#{ $!. class } "
14781473 truncate_prompt_main ( main_str )
14791474 when "M"
1480- main_str = basic_object_safe_main_call ( :inspect ) rescue "!#{ $!. class } "
1475+ main_str = @context . safe_method_call_on_main ( :inspect ) rescue "!#{ $!. class } "
14811476 truncate_prompt_main ( main_str )
14821477 when "l"
14831478 ltype
Original file line number Diff line number Diff line change @@ -704,5 +704,10 @@ def inspect # :nodoc:
704704 def local_variables # :nodoc:
705705 workspace . binding . local_variables
706706 end
707+
708+ def safe_method_call_on_main ( method_name )
709+ main_object = main
710+ Object === main_object ? main_object . __send__ ( method_name ) : Object . instance_method ( method_name ) . bind_call ( main_object )
711+ end
707712 end
708713end
You can’t perform that action at this time.
0 commit comments