Class: Breakpoint::DRbService

Inherits:
Object
  • Object
show all
Includes:
DRbUndumped
Defined in:
lib/active_record/support/breakpoint.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDRbService

Returns a new instance of DRbService.



269
270
271
272
273
274
# File 'lib/active_record/support/breakpoint.rb', line 269

def initialize
  @handler = @eval_handler = @collision_handler = nil

  IRB.instance_eval { @CONF[:RC] = true }
  IRB.run_config
end

Instance Attribute Details

#eval_handlerObject (readonly)

Returns the value of attribute eval_handler.



301
302
303
# File 'lib/active_record/support/breakpoint.rb', line 301

def eval_handler
  @eval_handler
end

Instance Method Details

#add_breakpoint(context, message) ⇒ Object



284
285
286
287
288
289
290
291
# File 'lib/active_record/support/breakpoint.rb', line 284

def add_breakpoint(context, message)
  workspace = IRB::WorkSpace.new(context)
  workspace.extend(DRbUndumped)

  sleep(0.5) until @handler

  @handler.call(workspace, message)
end

#collisionObject



276
277
278
279
280
# File 'lib/active_record/support/breakpoint.rb', line 276

def collision
  sleep(0.5) until @collision_handler

  @collision_handler.call
end

#pingObject



282
# File 'lib/active_record/support/breakpoint.rb', line 282

def ping; end

#register_collision_handler(&block) ⇒ Object



311
312
313
# File 'lib/active_record/support/breakpoint.rb', line 311

def register_collision_handler(&block)
  @collision_handler = block
end

#register_eval_handler(&block) ⇒ Object



303
304
305
# File 'lib/active_record/support/breakpoint.rb', line 303

def register_eval_handler(&block)
  @eval_handler = block
end

#register_handler(&block) ⇒ Object



293
294
295
# File 'lib/active_record/support/breakpoint.rb', line 293

def register_handler(&block)
  @handler = block
end

#unregister_collision_handlerObject



315
316
317
# File 'lib/active_record/support/breakpoint.rb', line 315

def unregister_collision_handler
  @collision_handler = lambda { }
end

#unregister_eval_handlerObject



307
308
309
# File 'lib/active_record/support/breakpoint.rb', line 307

def unregister_eval_handler
  @eval_handler = lambda { }
end

#unregister_handlerObject



297
298
299
# File 'lib/active_record/support/breakpoint.rb', line 297

def unregister_handler
  @handler = nil
end