Re: roles verify attribute contents when applied?

[email protected] (Mark Hedges)
Newsgroups perl.moose
Message-ID <[email protected]>

On Fri, 13 Jan 2012, Mark Hedges wrote:

> On Thu, 12 Jan 2012, Dave Rolsky wrote:
>
> > It seems to me that this would be better written like this:
> >
> >   package Machine;
> >   use Moose;
> >
> >   has power_cycler => (
> >       is => 'ro',
> >       does => 'PowerCycler',
> >       handles => [ 'restart' ],
> >   );

I guess this is not too difficult.  The builder for the
attribute will get the hardware type and pick the right
class, which consumes the parent role specified in 'does'.
In some ways maybe it is better, because if I have other
hardware-ish methods they can be organized in separate
utility object classes.

Mark
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.