Skip to content

steveg-h/persistent_object

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

persistent_object

Simple object persistence library for ruby built on sqlite database

PersitentObject is designed for use in embedded situations - the itch that needed to be scratchedwas ensuring that certain types of ruby objects could be persited through a reboot of the process or of the entire embedded platform

PersistentObject is built as a Module, so it can be added to any existing class structure Basically what it provides is a combination of YAML marshaling, with index fields to create a serachable database of marshalled objects

use

require 'persistent_object' class Foo include PersitentObject

attr_accessor :foo, :bar, :baz self.persists :foo, :bar # persisted variables act as inidices which acn be searched on

def initialize(f,b) @foo=f @bar=b end

end

f=Foo.new f.foo='a'; f.bar='b', f.baz='c'

f.save g=Foo.load(foo: 'a', bar: 'b') # will reload on f from the db into g h=Foo.load(foo: 'c', bar: 'd') # will create a new Foo, taking the persists arguments in order as constructor # arguments, up to the constructor arity

About

Simple object persistence library for ruby bulit on sqlite database

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages