I've been working on the following project for a while, mostly just to scratch my own itch:

http://code.google.com/p/perl-dbix-nailgun/source/browse/

It's heavily inspired by Ruby on Rails' implementation of Active Record, tweaked to be more Perlish.

It's supposed to literally grok the database structure and DWIM. By "literally grok", I mean _literally_ consume the database structure, and by consuming it, come to a full understanding of it. By DWIM, I mean DW _I_ M, but hopefully I'm sane enough that what I mean is what any sane person ought to mean.

The code snippet on the project front page says more than I think I could say in English, at least more tersely:

package MyApp::Photos;
use base qw(DBIx::Nailgun);
sub init {
    my $self = shift;
    $self
        ->validates_presence_of('filename')
        ->belongs_to('slides')
        ->has_and_belongs_to_many('categories')
    ;
}

package MyApp;
use Carp;
use MyApp::Photos;
use MyApp::Slideshows;
use MyApp::Categories;
my $photo = MyApp::Photos->find(23);
my $old_fn = $photo->{ filename };
$photo->{ filename } = 'cat.jpg';
push @{$photo->{ categories }}, MyApp::Categories->find_by({ name => 'Animals' });
$photo->save();
my $slideshow = MyApp::Slideshows->find_by({ title => 'My Pets' })->unique()
    or croak("More than one slideshow named 'My Pets'");
push @{$slideshow->{ slides }}, $photo;
$slideshow->save();

My question for you all is restated from the subject line:

Does this belong in CPAN (once it's finished off and polished a decent bit more)?



Thanks,



--
Paul Bennett (PWBENNETT)

Reply via email to