# File debug-1.4.0/lib/debug/breakpoint.rb, line 343 def initialize ivar, object, current, cond: nil, command: nil, path: nil @ivar = ivar.to_sym @object = object @key = [:watch, object.object_id, @ivar].freeze @current = current @cond = cond @command = command @path = path super() end
# File debug-1.4.0/lib/debug/breakpoint.rb, line 374 def setup @tp = TracePoint.new(:line, :return, :b_return){|tp| next if tp.path.start_with? __dir__ next if tp.path.start_with? '<internal:' watch_eval(tp) } end
# File debug-1.4.0/lib/debug/breakpoint.rb, line 383 def to_s value_str = if defined?(@prev) "#{@prev} -> #{@current}" else "#{@current}" end "#{generate_label("Watch")} #{@object} #{@ivar} = #{value_str}" end
# File debug-1.4.0/lib/debug/breakpoint.rb, line 356 def watch_eval(tp) result = @object.instance_variable_get(@ivar) if result != @current begin @prev = @current @current = result if (@cond.nil? || @object.instance_eval(@cond)) && !skip_path?(tp.path) suspend end ensure remove_instance_variable(:@prev) end end rescue Exception false end