Skip to content

Instantly share code, notes, and snippets.

@mikeymicrophone
Created September 15, 2009 23:30
Show Gist options
  • Save mikeymicrophone/187754 to your computer and use it in GitHub Desktop.
Save mikeymicrophone/187754 to your computer and use it in GitHub Desktop.
# a testing utility by Mike Harris
class PersistantHash
def [](k)
f = File.dirname(__FILE__) + "/phash/#{k}"
if File.exists?(f)
File.open(f) { |x| Marshal.load(x) }
else
nil
end
end
def []=(k,v)
f = File.dirname(__FILE__) + "/phash/#{k}"
File.open(f,File::CREAT|File::WRONLY) do |x|
Marshal.dump(v,x)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment