class Lorentz

Attributes

db[R]

Public Class Methods

new(opts={}) click to toggle source
# File lib/lorentz.rb, line 9
def initialize(opts={})
  db_name = opts.delete(:db) || 0

  @db = begin
          ::Maglev::PERSISTENT_ROOT[:"lorentz_db_#{db_name}"] ||= {}
        rescue
          $stderr.puts "Maglev only"
          exit
        end
end
version() click to toggle source
# File lib/lorentz/version.rb, line 3
def version
  "0.0.1".freeze
end

Private Instance Methods

run() { || ... } click to toggle source
# File lib/lorentz.rb, line 34
def run(&block)
  Maglev.abort_transaction
  yield
end
save() { || ... } click to toggle source
# File lib/lorentz.rb, line 23
def save(&block)
  begin
    Maglev.abort_transaction
    yield
    Maglev.commit_transaction
  rescue Maglev::CommitFailedException
    $stderr.puts "I tried to save but I couldn't. Trying again."
    redo
  end
end