Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: DBIx::Class Result classes using Moose

by tospo (Hermit)
on May 09, 2012 at 12:39 UTC ( #969609=note: print w/replies, xml ) Need Help??

in reply to DBIx::Class Result classes using Moose

Using Moose Roles in ResultSet Classes

turns out that this is a bit more tricky and needs some more magic. Thanks to the folks over on irc I found out that you need to fiddle with the BUILDARGS to make it work. So, the above code works for Result classes, while the following will enable Moose in your ResultSet classes:
package MyApp::Schema::ResultSet::Foo; use strict; use warnings; use Moose; use MooseX::NonMoose; use MooseX::MarkAsMethods autoclean => 1; extends 'DBIx::Class::ResultSet'; with 'SomeOldRole'; # insert your Role here... # This is the crucial bit - don't ask.... sub BUILDARGS { $_[2] } ### your ResultSet methods here ### __PACKAGE__->meta->make_immutable; 1;

Replies are listed 'Best First'.
Re^2: DBIx::Class Result classes using Moose
by mcsnolte (Initiate) on Aug 13, 2012 at 17:20 UTC

    When using MooseX::NonMoose in my ResultSet class as described here I find that calling new() on it fails when it tries to proxy over to new_result().

    Is this a known bug (or limitation) of MooseX::NonMoose? Or am I doing something wrong?

    Error I get (on DBIx-Class-0.08196):

    Can't call method "isa" on unblessed reference at DBIx::Class::ResultSet::new(/usr/local/share/perl/5.10.1/DB +Ix/Class/
      sorry for the delay - haven't been in here for a while... Can't even help you much I'm afraid. It worked fine for me. Can you post some code?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://969609]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2018-06-24 11:52 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.