Og (ObjectGraph) is an efficient, yet simple Object-Relational mapping library.
The library provides the following features:
+ Object-Relational mapping. + Absolutely no configuration files. + Multiple backends (PostgreSQL, MySQL). + ActiveRecord-style meta language and db aware methods. + Deserialize to Ruby Objects or ResultSets. + Deserialize sql join queries to Ruby Objects. + Serialize arbitrary ruby object graphs through YAML. + Connection pooling. + Thread safety. + SQL transactions. + Lifecycle callbacks. + Transparent support for cascading deletes for all backends. + Hierarchical structures (preorder traversal, materialized paths) + Works safely as part of distributed application. + Simple implementation.
primary_key :pid (NOT IMPLEMENTED) name_key :name (NOT IMPLEMENTED) prop_accessor Fixnum, :pid, :sql => "smallint DEFAULT 1" has_many Child, :children many_to_many Role, :roles sql_index :pid
Keep the main classes backend agnostic. For class ids we use the name instead of a hash. Class ids are typically not used in querys, they are stored for completeness. If we store a hash we cannot reclaim the class thus invalidating the point. Instead of .name(), to_s() is used so the methods are more flexible (they accept class names too!!)
Og allows the serialization of arbitrary Ruby objects. Just mark them as Object (or Array or Hash) in the prop_accessor and the engine will serialize a YAML dump of the object. Arbitrary object graphs are supported too.
This is NOT a singleton, an application may access multiple databases.
The og.xxx methods are more flexible and allow you to use multiple databases for example.
* og_pre_update
A class level callback is used for delete because typically you call delete with an oid and not an object to avoid a deserialization.
Version | = | '0.9.5' | The version of Og. |