2009/4/14 Zbigniew Lukasiak <[email protected]>:
> Ah - sorry I was not specific enough. What I had in mind was more
> something similar to
>
> with ValidationRoleSomething;
> with ValidationRoleSomethingElse;
> with ValidationRoleEntirelyDifferent;
>
> and all those Roles providing a 'validate' method without a conflict.
> Then when $object->validate is called it calls all the 'validate'
> methods provided by the Roles in some sequence.
You just described how roles work :)
You should place into your role something like:
around 'validate' => sub {
my ($next, $self) = @_;
# here your code
return $self->$next();
};
"around" guarantees that you're roles won't conflict.
--
.''`. Piotr Roszatycki
: :' : mailto:[email protected]
`. `' mailto:[email protected]
`-