public
Description: Data::ObjectDriver is Six Apart's Perl ORM
Home | Edit | New

Home

What?

This is an import of Six Apart’s subversion

You can fork away and hack on it. Please note that subversion is still the central authority place for all things Data::ObjectDriver

Hacking on Moose

I’m currently leaning moose, and I’m hacking around, fiddling with DOD’s guts. Comments appreciated (I’m learning!). This is currently happening in my moose branch.

If you really want a more Stable Moose based ORM, please consider Fey::ORM, Moose + DBIx::Class, Reaction… this is just a toy

why?

I really like a few things in DOD (and I really dislike some other), so I don’t want to change everything, but I hope the nicest concept of Moose can help make DOD more elegant without making it cumbersome. If I really like it I might fork another project away since it’s not likely that DOD will get a Moose upgrade in the near future.

How does that look like?


package Ingredient;

use Data::ObjectDriver::Moose;
use Moose::Util::TypeConstraints;

subtype 'vchar'
    => as Str
    => where { defined($_) && bytes::length($_) < 255 }
    => message { "The vchar you provided shouldn't exceed 255 char" };

has id        => ( isa => 'Int', is => 'rw' );
has recipe_id => ( isa => 'Int', is => 'rw' );
has quantity  => ( isa => 'Int', is => 'rw' );
has name      => ( isa => 'vchar', is => 'rw' );

use Carp ();
use Data::ObjectDriver::Driver::DBI;
use Data::ObjectDriver::Driver::Cache::RAM;

our %IDs;

columns     ( 'all', except => [] );
datasource  ( 'ingredients' );
primary_key ( ['recipe_id', 'id'] );
driver      ( Data::ObjectDriver::Driver::Cache::RAM->new(
    fallback => Data::ObjectDriver::Driver::DBI->new(
        dsn      => 'dbi:SQLite:dbname=global.db',
        pk_generator => \&generate_pk,
        reuse_dbh => 1,
    ),
    pk_generator => \&generate_pk,
));


Last edited by yannk, Fri Apr 03 23:25:25 -0700 2009
Home | Edit | New
Versions: