Moose with Rose::DB::Object. Roose? Morose?

May 7th, 2009 by Rohan

Yeah, I know it sounds silly. I’ve now read the Rose::DB::Object tutorial and the Moose manual several times and can’t wait to get started on my current and future projects using these technologies.

I find Rose::DB::Object to be a refreshing change over all the ORMs out there, and I especially like the concept of Manager classes. The docs are quite well written with several practical examples and its a good read to review your knowledge of database design too.

Moose is all the hype these days. Its so easy to get started using it and again - the manual is well written.

So I’m wondering how I will use these two modules together to get a persistent object system in my applications. From my searches, I found that there are examples of where people have used Moose and DBIx::Class together, but I couldn’t find samples with Rose::DB::Object. Anyway, I’ve decided to tackle this myself.

[Post to Twitter] Tweet This Post  [Post to Facebook] Facebook 

3 Responses to “Moose with Rose::DB::Object. Roose? Morose?”

  1. john napiorkowski Says:

    Moose has a lot of ways to be compatible with non Moose based classes. Although several options are ‘baked’ in, there is now a module on CPAN to make it even more clear: “http://search.cpan.org/dist/MooseX-NonMoose/” This module makes is easy to extend non Moose classes into Moose, although you do have other options they might be better such as delegation (see “http://search.cpan.org/~drolsky/Moose-0.77/lib/Moose.pm” and look for the ‘handles’ option on attributes).

    I’d say the main reason why there’s a lot going on between the DBIC (DBIx::Class) group and Moose is that most of the people contributing to DBIC are also heavy Moose contributors. Also, there’s a planned port of DBIC to Moose, which again is going to increase the level of communication between the groups.

  2. jdv Says:

    Good luck. But last time I checked with the rose and moose people this was just not possible.
    Your first hurdle (perhaps the only one) is meta.

  3. John Says:

    One issue you may encounter is that both Moose and Rose::DB::Object define and rely on a method named meta(). (For the record, Rose::DB::Object had it first.) This means that you can’t make a Rose::DB::Object-derived class that also inherits from Moose, and you can’t make a Moose class that inherits from a Rose::DB::Object-derived class.

    What people usually do instead is use composition rather than inheritance. That is, make a Moose-derived class that “has a” Rose::DB::Object-derived object within it, rather than one that “is a” (i.e., inherits from) Rose::DB::Object. The reverse will also work: a Rose::DB::Object-derived object that “has a” Moose-derived object.

    Good luck! And don’t forget about the Rose::DB::Object mailing list if you run into any problems: http://groups.google.com/group/rose-db-object

Leave a Reply




Tweet This Post links powered by Tweet This v1.4.1, a WordPress plugin for Twitter.