summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/MooseX/ABC/Trait/Class.pm15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/MooseX/ABC/Trait/Class.pm b/lib/MooseX/ABC/Trait/Class.pm
index bca130f..b47bea0 100644
--- a/lib/MooseX/ABC/Trait/Class.pm
+++ b/lib/MooseX/ABC/Trait/Class.pm
@@ -9,7 +9,8 @@ has required_methods => (
default => sub { [] },
auto_deref => 1,
provides => {
- push => 'add_required_method',
+ push => 'add_required_method',
+ empty => 'has_required_methods',
},
);
@@ -30,6 +31,18 @@ after _superclasses_updated => sub {
}
}
}
+
+ return if $self->has_required_methods;
+
+ # at this point, the current class didn't have any required methods to
+ # start with, and all of the required methods from superclasses have
+ # been satisfied, so restore the constructor
+
+ my $constructor = $self->find_method_by_name('new');
+ if ($constructor->original_package_name eq 'MooseX::ABC::Role::Object') {
+ my $moose_constructor = Class::MOP::class_of('Moose::Object')->get_method('new');
+ $self->add_method(new => $moose_constructor->clone);
+ }
};
no Moose::Role;