[Catalyst] ActionClass vs. Moose Role?
bobtfish at bobtfish.net
Fri Aug 28 17:29:44 GMT 2009
On 28 Aug 2009, at 18:25, Bill Moseley wrote:
> I was starting to implement a custom ActionClass (similar to
> RenderView) and then wondered if it would be better written as a
> Moose role.
Maybe - depends what you're doing. They're doing different things
really, and I'd need more details to make a recommendation.
> Is there a reason to use one over another?
> Last I looked, an action is limited to a single ActionClass
> (although it's easy to deal with that), but depending on how it's
> done, could apply multiple roles.
Catalyst::Controller::ActionRole gets around this, you can apply many
roles to your action.
> That is, one way would be to define the end() method in the role and
> not even have it in the consuming controller class, or another would
> be to have a end() stub
> in the controller and and then use "before 'end'" in the role. That
> way multiple roles could be applied.
Yep, that also totally works.
> Is everything going to be a role at some point? ;)
Not _everything_, but yes - a lot of stuff..
More information about the Catalyst