in reply to Re: Abstract Methods in Moose
in thread Abstract Methods in Moose
Hm. I believe the requires is provided by Moose::Role, and hence has the limitations outlined in the documentation.
What it comes down is that while I can use a role to require a method definition directly in a class, I can't "defer" the method definition until later in the class hierarchy. That is, the following would work:
but the following (which is what I'd want) wouldn't:package WidgetRole; use Moose::Role; requires 'get_widget_type'; package AbstractWidget; use Moose; with 'WidgetRole'; sub get_widget_type{ "IAmAbstract" }
package WidgetRole; use Moose::Role; requires 'get_widget_type'; package AbstractWidget; use Moose; with 'WidgetRole'; package SnazzyWidget; use Moose; extends 'AbstractWidget'; sub get_widget_type{ "BasicWidget" } # throws error and dies
So I don't think roles/using requires is what I am looking for. But maybe I'm wrong - I have all of five days of experience with Moose!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Abstract Methods in Moose
by ikegami (Patriarch) on Dec 12, 2009 at 21:56 UTC | |
Re^3: Abstract Methods in Moose
by Anonymous Monk on Dec 11, 2009 at 21:10 UTC |
In Section
Seekers of Perl Wisdom