summaryrefslogtreecommitdiffstats
path: root/lib/MooseX/ABC/Trait/Class.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/MooseX/ABC/Trait/Class.pm')
-rw-r--r--lib/MooseX/ABC/Trait/Class.pm12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/MooseX/ABC/Trait/Class.pm b/lib/MooseX/ABC/Trait/Class.pm
index edc91d2..e54e70b 100644
--- a/lib/MooseX/ABC/Trait/Class.pm
+++ b/lib/MooseX/ABC/Trait/Class.pm
@@ -12,6 +12,12 @@ dying if a subclass doesn't implement the required methods.
=cut
+has is_abstract => (
+ is => 'rw',
+ isa => 'Bool',
+ default => 0,
+);
+
has required_methods => (
traits => ['Array'],
is => 'ro',
@@ -26,12 +32,14 @@ has required_methods => (
after _superclasses_updated => sub {
my $self = shift;
+ return if $self->is_abstract;
my @supers = $self->linearized_isa;
shift @supers;
for my $superclass (@supers) {
my $super_meta = Class::MOP::class_of($superclass);
next unless $super_meta->meta->can('does_role')
&& $super_meta->meta->does_role('MooseX::ABC::Trait::Class');
+ next unless $super_meta->is_abstract;
for my $method ($super_meta->required_methods) {
if (!$self->find_method_by_name($method)) {
my $classname = $self->name;
@@ -48,7 +56,7 @@ around _immutable_options => sub {
my $self = shift;
my @options = $self->$orig(@_);
my $constructor = $self->find_method_by_name('new');
- if ($self->has_required_methods) {
+ if ($self->is_abstract) {
push @options, inline_constructor => 0;
}
# we know that the base class has at least our base class role applied,
@@ -57,7 +65,7 @@ around _immutable_options => sub {
&& $constructor->get_original_method == Class::MOP::class_of('Moose::Object')->get_method('new')) {
push @options, replace_constructor => 1;
}
- # if our parent has been inlined and we have no required methods, then it's
+ # if our parent has been inlined and we are not abstract, then it's
# safe to inline ourselves
elsif ($constructor->isa('Moose::Meta::Method::Constructor')) {
push @options, replace_constructor => 1;