[Skip To Content]


# PermaStore

  1. class PermaStore < Hash
  2. def self.load
  3. if File.exists?( "data.dump" )
  4. File.open( "data.dump", "r" ) do |f|
  5. return Marshal.load( f )
  6. end
  7. end
  8. return PermaStore.new
  9. end
  10. def []=( key, value )
  11. super
  12. save
  13. end
  14. def delete( value )
  15. super
  16. save
  17. end
  18. protected
  19. def save
  20. File.open( "data.dump", "w" ) do |f|
  21. Marshal.dump( self, f )
  22. end
  23. end
  24. end

Do whatever you will with it. It’s not thread safe, but that’s easily fixable if you’re so inclined.

More about this site...

Last Week’s Top 5 Albums (More »)

  1. Checkmate SavageThe Phantom Band
  2. Port Of MorrowThe Shins
  3. FalconThe Courteeners
  4. Broken BellsBroken Bells
  5. The Stars are Indifferent to AstronomyNada Surf