Skip to content

Instantly share code, notes, and snippets.

@havenwood

havenwood/thaw.rb

Created Feb 1, 2019
Embed
What would you like to do?
Example #thaw, #unfreeze and such for #ruby IRC.
require 'fiddle'
module Kernel
def thaw
pointer[1] = 0
self
end
alias unfreeze thaw
def toggle_frozen
pointer[1] ^= 8
self
end
def toggle_tainted
pointer[1] ^= 1
self
end
private def pointer
Fiddle::Pointer.new object_id << 1
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment