greengaroo has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks,
I am reaching out to those of you who have experience with Moose and MooseX-Declare.
I have created an Abstract class and it works fine, I just want to know if there is a better way to do it, more specifically, the part where we prevent instantiation of this Abstract class.
So, this is how I do it:
use MooseX::Declare; class AbstractClass { sub BUILD { my $self = shift; # This is the mechanism that prevents instantiation if ( ref($self) eq __PACKAGE__ ) { # throw exception here } } # other methods go here }
Anyone knows a better way to do it? Should I expect problems from doing this?
Thank you!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Abstract class under MooseX-Declare
by tobyink (Canon) on Aug 09, 2012 at 21:27 UTC | |
by greengaroo (Hermit) on Aug 10, 2012 at 14:54 UTC | |
by tobyink (Canon) on Aug 10, 2012 at 21:31 UTC | |
|
Re: Abstract class under MooseX-Declare
by grondilu (Friar) on Aug 08, 2012 at 18:56 UTC | |
by greengaroo (Hermit) on Aug 09, 2012 at 21:15 UTC |