mascip has asked for the wisdom of the Perl Monks concerning the following question:
Hello,
with Moose i used MooseX::ClassAttribute to declare class attributes. I am thinking about transitioning to Moo, and am wondering how to best deal with class attributes.
For example, i am sharing a timer between all the objects of a class. I used to write
package MyClass; use Moose; use MooseX::ClassAttribute; class_has 'timer' => ( is => 'ro', isa => 'Benchmark::Timer', default => sub { Benchmark::Timer->new() }, );
Now with Moo i have just used the "good old way" (maybe not that "good"?) :
Is there any nicer way to do that?package MyClass; use Moo; my $timer = Benchmark::Timer->new();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Class Attributes with Moo ?
by tobyink (Canon) on Dec 27, 2012 at 07:53 UTC | |
by mascip (Pilgrim) on Dec 27, 2012 at 16:22 UTC | |
by tobyink (Canon) on Jan 01, 2013 at 10:37 UTC | |
by mascip (Pilgrim) on Jan 01, 2013 at 16:37 UTC | |
by mascip (Pilgrim) on Dec 28, 2012 at 07:29 UTC |