module PryMoves::TracedMethod
Private Instance Methods
before_end?(line)
click to toggle source
# File lib/pry-moves/traced_method.rb, line 57 def before_end?(line) @method[:end] and line < @method[:end] end
find_method_definition(binding)
click to toggle source
# File lib/pry-moves/traced_method.rb, line 24 def find_method_definition(binding) method_name, obj, line, file = binding.eval '[__method__, self, __LINE__, __FILE__]' return unless method_name method = obj.method(method_name) return method if method.source_location[0] == file # If found file was different - search definition at superclasses: obj.class.ancestors.each do |cls| if cls.instance_methods(false).include? method_name method = cls.instance_method method_name return method if method.source_location[0] == file end end pry_puts "⚠️ Unable to find definition for method #{method_name} in #{obj}" nil end
set_method(method)
click to toggle source
# File lib/pry-moves/traced_method.rb, line 45 def set_method(method) #puts "set_traced_method #{method}" @method = method end
set_traced_method(binding)
click to toggle source
# File lib/pry-moves/traced_method.rb, line 5 def set_traced_method(binding) @recursion_level = 0 @c_stack_level = 0 @stay_at_frame = nil # reset tracked digest method = find_method_definition binding if method source = method.source_location set_method({ file: source[0], start: source[1], name: method.name, end: (source[1] + method.source.count("\n") - 1) }) else set_method({file: binding.eval('__FILE__')}) end end
within_current_method?(file, line)
click to toggle source
# File lib/pry-moves/traced_method.rb, line 50 def within_current_method?(file, line) @method[:file] == file and ( @method[:start].nil? or line.between?(@method[:start], @method[:end]) ) end