KSURi has asked for the wisdom of the Perl Monks concerning the following question:
package Foo; use Moose; coerce 'ArrayRef' => from 'Int' => via { [$_] }; has attr => ( is => 'rw', isa => 'ArrayRef[Int]', coerce => 1, ); # ... 1
When I try to use both classes in one script I get this:package Bar; use Moose; coerce 'ArrayRef' => from 'Int' => via { [$_] }; has another_attr => ( is => 'rw', isa => 'ArrayRef[Int]', coerce => 1, + ); # ... 1
The problem is that I have scripts which uses both Foo and Bar, and scripts which uses only one of them. So I have to define coercion in both classes.A coercion action already exists for 'Int' at /usr/lib/perl5/site_perl +/5.8.8/Moose/Meta/TypeCoercion.pm line 87
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Can't use two Moose classes with the same coercion action
by j1n3l0 (Friar) on Apr 24, 2009 at 15:22 UTC | |
by KSURi (Monk) on Apr 24, 2009 at 15:54 UTC | |
Re: Can't use two Moose classes with the same coercion action
by ww (Archbishop) on Apr 24, 2009 at 14:47 UTC | |
by ikegami (Patriarch) on Apr 24, 2009 at 15:11 UTC | |
by Anonymous Monk on Apr 24, 2009 at 15:17 UTC | |
Re: Can't use two Moose classes with the same coercion action
by castaway (Parson) on Apr 25, 2009 at 21:07 UTC | |
by KSURi (Monk) on Apr 27, 2009 at 10:59 UTC |