smtlaissezfaire / odb

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ODB

The ruby object database

Notes:

This stuff is still in pre-alpha. Don’t expect it to work for anything useful just quite yet.

Installation

./bin/odb-install

Usage

Process 1

# Set up ODB
require 'lib/odb'
Odb.path = "."

# Load your classes, data
class Foo
  attr_accessor :bar
end

f = Foo.new
f.bar = "a_value"
a = [1, "bar", f]

# store your data
Odb::Object.write(a) #=> 4 (the object_id)

Process 2

# Set up ODB
require 'lib/odb'
Odb.path = "."

# Load your classes
class Foo
  attr_accessor :bar
end

# Read + Write your data
>> a = Odb::Object.read(4)
=> [object_id:0, object_id:1, object_id:3]
>> a[0]
=> 1
>> a[1]
=> "bar"
>> a[2]
=> #<Foo:0x10115d018 @bar="a_value">

Bugs

  • User written C classes not supported

  • Any class which doesn’t return the class name with “to_s” won’t be loadable.

  • No support for anything Marshal doesn’t support: Classes, Procs, Lambdas, Methods, UnboundMethods

About

License:GNU General Public License v3.0


Languages

Language:Ruby 100.0%