[Dbix-class] Adding Class::Workflow data to a DBIx::Class object
Matt S Trout
dbix-class at trout.me.uk
Wed Oct 3 23:51:59 GMT 2007
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' => (
> is => 'rw',
> isa => '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) = @_;
>
> my $workflow = Class::Workflow->new;
> my $new = $class->next::method($attrs);
>
> # Neither of the following two work, both give the same error (see below)
> $new->{workflow} = $workflow;
> $new->workflow($workflow);
> }
It would help if you actually returned $new at the end of the method ...
--
Matt S Trout Need help with your Catalyst or DBIx::Class project?
Technical Director http://www.shadowcat.co.uk/catalyst/
Shadowcat Systems Ltd. Want a managed development or deployment platform?
http://chainsawblues.vox.com/ http://www.shadowcat.co.uk/servers/
More information about the DBIx-Class
mailing list