Skip to content

Instantly share code, notes, and snippets.

@lsegal
Created November 27, 2009 01:44
Show Gist options
  • Save lsegal/243771 to your computer and use it in GitHub Desktop.
Save lsegal/243771 to your computer and use it in GitHub Desktop.
class Post
include ODB::Persistent
attr_accessor :title, :author
def __serialize_key__; title.to_sym end
end
db = ODB.new
post = nil
db.transaction do
post = Post.new.tap {|p| p.title = "x"; p.author = "Joe" }
end
db.store[:x] == post # => true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment