سؤال

In Ruby on Rails while debugging is there any way where we can ask the debugger to break the execution as soon as a value at specific memory location or the value of a variable/object changes ?

هل كانت مفيدة؟

المحلول

How much of a break in execution do you want?

If the variable is set from outside the instance, then it will be being accessed via some method. You could overwrite such a method just for this purpose.

# define
class Foo
  def bar
    @bar ||= 'default'
  end

  def bar=(value)
    @bar = value
  end
end

# overwrite
class Foo
  def bar=(value)
    super
    abort("Message goes here")
  end
end
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top