[Dbix-class] Adding Class::Workflow data to a DBIx::Class object

Ian Docherty dbix-class at iandocherty.com
Thu Oct 4 05:24:12 GMT 2007


Matt S Trout wrote:
> On Wed, Oct 03, 2007 at 07:10:56PM +0100, Ian Docherty wrote:
>   =

>> I am using Moose, but I don't think that is the problem.
>>
>> I want to over-ride 'new' whenever I create a 'Demo' object and add a =

>> Class::Workflow object to my DBIx::Class object. My code is:-
>> ----------------
>> package MyApp::Domain::Result::Demo;
>>
>> use Moose;
>> use Class::Workflow;
>>
>> BEGIN {
>> extends 'DBIx::Class';
>> };
>>
>> has 'workflow' =3D> (
>>    is          =3D> 'rw',
>>    isa         =3D> 'Class::Workflow',
>> );
>>
>> __PACKAGE__->load_components(qw(PK::Auto Core));
>> __PACKAGE__->table('demo');
>> __PACKAGE__->add_columns(qw(id name value state creator owner));
>> __PACKAGE__->set_primary_key('id');
>>
>> sub new {
>>    my ($class, $attrs) =3D @_;
>>
>>    my $workflow =3D Class::Workflow->new;
>>    my $new =3D $class->next::method($attrs);
>>
>> # Neither of the following two work, both give the same error (see below)
>>    $new->{workflow} =3D $workflow;
>>    $new->workflow($workflow);
>> }
>>     =

>
> It would help if you actually returned $new at the end of the method ...
>   =

Drat. So obvious when you see it! It must have got deleted at some point =

since it was there to start. Thanks!

Regards
Ian

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20071004/196=
b17c8/attachment-0001.htm


More information about the DBIx-Class mailing list