Very interesting. Where it's possible to look at sources? 2010/3/24 Moritz Onken <[email protected]>: > Hi, > > the latest discussion about using Moose and DBIC got me thinking and I > started a little proof of concept project. > It's called MooseX:DBIC. It contains a MooseX::DBIC::Schema class which is > a subclass of DBIx::Class::Schema. > > The idea is to have a layer which takes Moose classes and generates a dbic > schema, including column information and relationships. > > package User; > use Moose; > has [qw(first last email password)] => ( is => 'rw', isa => 'Str' ); > > sub talk { 'Hello' } > > and load this class in the schema: > > package MySchema; > use Moose; > extends 'MooseX::DBIC::Schema'; > __PACKAGE__->load_classes('User'); > > This will create the following classes: > > MySchema::DBIC::User (which isa DBIx::Class ResultSource class) > and > MySchema::User (which isa "User" and does MooseX::DBIC::Result) > > inflate_result in MySchema::DBIC::User is extended to return a > MySchema::User object instead of MySchema::DBIC::User. And MySchema::User > has an attribute "dbic_result" which is set to the dbic result row object. > > MySchema::User inherits from "User" and can be extended by a custom role to > change column_info and more dbic related stuff. > MooseX::DBIC::Result adds proxy methods to MySchema::User (i.e. > create/update/delete) which update the dbic result object. > > Example: > > my $user = $schema->resultset('User')->create({ first => 'foo' }); > # $user isa User, does MooseX::DBIC::Result > $user->talk; # Hello > > It works well so far, but obviously a lot of things are still missing. One > nice feature I implemented is subclassing. Imagine a class Admin which > extends User and has some additional attributes. MooseX::DBIC::Schema will > create two tables and the relationship admin has_one user. > > I just wanted to collect some opinions about this idea. If someone comes up > with a good argument why this is retarded, please tell so I can stop > wasting my time on this. > > cheers, > mo > > _______________________________________________ > List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class > IRC: irc.perl.org#dbix-class > SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/ > Searchable Archive: http://www.grokbase.com/group/[email protected] >
-- Sincerely yours, Oleg Kostyuk (CUB-UANIC) _______________________________________________ List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/ Searchable Archive: http://www.grokbase.com/group/[email protected]
