fork download
  1. require 'fiddle'
  2.  
  3. def with_ephemeral_inclusion obj
  4. fp = Fiddle::Pointer.new obj.__id__ * 2
  5. sol = Fiddle::SIZEOF_LONG
  6.  
  7. orig = fp[sol * 2, 4]
  8. obj.instance_eval &proc
  9. fp[sol * 2, 4] = orig
  10. end
  11.  
  12. A = Module.new
  13. B = Module.new
  14.  
  15. with_ephemeral_inclusion Object do
  16. include A
  17. include B
  18. p ancestors
  19. end
  20.  
  21. p Object.ancestors
Success #stdin #stdout 0.05s 9824KB
stdin
Standard input is empty
stdout
[Object, B, A, Kernel, BasicObject]
[Object, Kernel, BasicObject]