Sha256: e2c524885c677c24e35ed91b4c90b68a3953d59fadd4d765184bef1cddbf55d6

Contents?: true

Size: 316 Bytes

Versions: 2

Compression:

Stored size: 316 Bytes

Contents

require 'rubygems'
require 'activesupport' #to_yaml

class PHash < Hash
  def initialize(path)
    @path = path
    if File.exist?(@path)
      data = YAML.load(File.read(@path)) rescue nil
      self.replace(data) if data
    end
  end
  
  def flush
    File.open(@path,'w') { |f| f.write(self.to_yaml)}
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
whistle-0.1.1 lib/phash.rb
whistle-0.1 lib/phash.rb