[Catalyst] Trouble getting attribute parameters for action classes
Matt S Trout
dbix-class at trout.me.uk
Thu Oct 12 20:30:43 CEST 2006
John Napiorkowski wrote:
> Hi,
>
> I'm working on an action class and trying to
> understand how parameters are passed into attributes.
>
> If I call an action class like this:
>
> sub test :Local ActionClass('test') myAttr() {}
>
> in the action class match I can check for that custom
> attribute like so:
>
> sub match
> {
> my $self = shift @_;
> my ($c) = @_;
>
> return 1 unless exists $self->attributes->{myAttr};
>
> my @params = @{$self->attributes->{myAttr}};
>
> ...
> }
>
> However no matter what I use for attribute parameters
> that @params always has a single entry. I figure I
> must be doing something wrong because if the attribute
> is only allowed to have a single parameter why bother
> to have it in an array ref?
>
> I've tried:
>
> myAttr(a,b,c)
> myAttr('a','b','c')
> myAttr(qw/a b c/)
>
> but the @params from the example above always ends up
> having:
>
> $params[0] = "a,b,c";
> $params[0] = "a','b','c";
> $params[0] = "qw/a b c/";
>
> and the like.
>
> Does anyone know what I am doing incorrectly?
sub foo :myAttr(a) :myAttr(b) :myAttr(c)
--
Matt S Trout Offering custom development, consultancy and support
Technical Director contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd. mst (at) shadowcatsystems.co.uk for more information
+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +
More information about the Catalyst
mailing list