summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2009-05-28 23:17:21 -0500
committerJesse Luehrs <doy@tozt.net>2009-05-28 23:17:21 -0500
commit058f1be1e12a7ce1438702f9a88046c076cdb5a3 (patch)
tree0ce4056685673425bca5ed4714a350fc713a61cc
parent839a7def505a875a02a0c4d8a56079298f56dca6 (diff)
downloadmoosex-abc-058f1be1e12a7ce1438702f9a88046c076cdb5a3.tar.gz
moosex-abc-058f1be1e12a7ce1438702f9a88046c076cdb5a3.zip
if a class satisfies all its requirements, restore the constructor
-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;