Re: roles verify attribute contents when applied?

[email protected] (Edward Allen)
Newsgroups perl.moose
Message-ID <CAPaaNjVOC54uJ8ZPVJ3nZdFxN_j6Ou-M2gYrciwjXWMnaL1KNw@mail.gmail.com>
I'm not sure how applying different roles to provide a standard method
is less complicated than delegating this method to various objects.
Using an object may be abstract and indirect, but fairly flexible and
a pretty standard thing to do.

On Fri, Jan 13, 2012 at 3:39 PM, Mark Hedges <[email protected]> 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' ],
>>   );
>>
>> In other words, make a separate object that represents the
>> type of power cycler (or whatever you call it) and let
>> that handle restarting the machine.
>
> I haven't communicated clearly.  There may be a number of
> different ways to power cycle depending on the attributes of
> the host.  The point was to separate them into classes, then
> add the right one to the machine object, granting a uniform
> method that does what I mean.  There may be other methods
> that come along with being one or another kind of hardware.
> This seems over-abstract and indirect.
>
> 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.