Sha256: e95ff7844e6495df228a9ac3ef622a00c7260b799e32d9ae65784924d580ad0d

Contents?: true

Size: 628 Bytes

Versions: 8

Compression:

Stored size: 628 Bytes

Contents

require 'yaml'
require 'fileutils'

require 'supermodel'

# A simple means of persistence
# This can easily be swapped out for redis, but file-based is simpler and good enough for now
# https://github.com/maccman/supermodel/blob/master/README
module Memory
  extend self
  DATABASE_PATH = (ENV['DATABASE_PATH'] || File.expand_path('../data/memory.db', $0)).freeze
  SuperModel::Marshal.path = DATABASE_PATH

  def save
    FileUtils.mkdir_p(File.dirname(DATABASE_PATH)) # FIXME - don't make if it already exists
    SuperModel::Marshal.dump
  end

  def load
    SuperModel::Marshal.load
  end
end

at_exit do
  Memory.save
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
zygote-0.1.5 lib/zygote/memory.rb
zygote-0.1.4 lib/zygote/memory.rb
zygote-0.1.3 lib/zygote/memory.rb
zygote-0.1.2 lib/zygote/memory.rb
zygote-0.1.1 lib/zygote/memory.rb
zygote-0.1.0 lib/zygote/memory.rb
zygote-0.0.9 lib/zygote/memory.rb
zygote-0.0.8 lib/zygote/memory.rb