diff options
author | Jesse Luehrs <doy@tozt.net> | 2009-05-29 00:05:47 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2009-05-29 00:05:47 -0500 |
commit | c94b01a949eadbc8864eac775c526ed8ffeeb98b (patch) | |
tree | ad5056ea2aaff8418ca2fa2d72c8df6da5bbe7a3 /lib/MooseX/ABC/Role/Object.pm | |
parent | b4043c557cfe277054e1077124d679aa24bda89c (diff) | |
download | moosex-abc-c94b01a949eadbc8864eac775c526ed8ffeeb98b.tar.gz moosex-abc-c94b01a949eadbc8864eac775c526ed8ffeeb98b.zip |
use better logic in the constructor rather than replacing it manually
Diffstat (limited to 'lib/MooseX/ABC/Role/Object.pm')
-rw-r--r-- | lib/MooseX/ABC/Role/Object.pm | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/MooseX/ABC/Role/Object.pm b/lib/MooseX/ABC/Role/Object.pm index 083c0f5..778a81a 100644 --- a/lib/MooseX/ABC/Role/Object.pm +++ b/lib/MooseX/ABC/Role/Object.pm @@ -1,12 +1,14 @@ package MooseX::ABC::Role::Object; use Moose::Role; -sub new { +around new => sub { + my $orig = shift; my $class = shift; - Class::MOP::class_of($class)->throw_error( - "$class is abstract, it cannot be instantiated" - ); -} + my $meta = Class::MOP::class_of($class); + $meta->throw_error("$class is abstract, it cannot be instantiated") + if $meta->has_required_methods; + $class->$orig(@_); +}; no Moose::Role; 1; |