Sha256: 843950f317c229630e33a6f728ab046712b38460516084c01467a29aaa230b65

Contents?: true

Size: 640 Bytes

Versions: 12

Compression:

Stored size: 640 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', $PROGRAM_NAME)).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

12 entries across 12 versions & 1 rubygems

Version Path
zygote-0.2.11 lib/zygote/memory.rb
zygote-0.2.10 lib/zygote/memory.rb
zygote-0.2.9 lib/zygote/memory.rb
zygote-0.2.8 lib/zygote/memory.rb
zygote-0.2.7 lib/zygote/memory.rb
zygote-0.2.6 lib/zygote/memory.rb
zygote-0.2.5 lib/zygote/memory.rb
zygote-0.2.4 lib/zygote/memory.rb
zygote-0.2.3 lib/zygote/memory.rb
zygote-0.2.2 lib/zygote/memory.rb
zygote-0.2.1 lib/zygote/memory.rb
zygote-0.2.0 lib/zygote/memory.rb