Module: WatchPoint
- Defined in:
- lib/watch_point.rb,
lib/watch_point/version.rb
Constant Summary collapse
- VERSION =
'0.0.1'
Class Method Summary collapse
Class Method Details
.disable ⇒ Object
59 60 61 |
# File 'lib/watch_point.rb', line 59 def disable set_trace_func(nil) end |
.enable ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/watch_point.rb', line 28 def enable set_trace_func(proc do |event, _, _, _, b, _| if @interactive_thread && Thread.current != @interactive_thread @sleeping_threads << Thread.current Thread.stop end next if event != 'line' @watch_list.each do |obj, hash0| if obj.hash != hash0 self.unwatch(obj) @interactive_thread = Thread.current # puts "Object #{obj} changed!" @last_binding.pry @interactive_thread = nil @sleeping_threads.each(&:wakeup) @sleeping_threads = [] self.watch(obj) break end end @last_binding = b end) end |
.unwatch(obj) ⇒ Object
22 23 24 25 26 |
# File 'lib/watch_point.rb', line 22 def unwatch(obj) @watch_list.delete_if do |obj1, _| obj.object_id == obj1.object_id end end |
.watch(obj) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/watch_point.rb', line 13 def watch(obj) if @watch_list.any? { |obj1, _| obj1.object_id == obj.object_id } raise ArgumentError, "Already watching object ##{obj.object_id}" end @watch_list << [obj, obj.hash] @last_binding ||= binding end |