X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FStrictConstructor%2FTrait%2FClass.pm;h=579b6c25d81156b7fc9f68afdc7ec7545590d34d;hb=0dc0aea2e2ce6e27b488b6e6d304c5ab19649745;hp=1bfb0f57fa090fe24c0f40e3f5f770ed1a7a0a1d;hpb=d99e6f32565008c417a6bf7a3335942df1f67e1b;p=gitmo%2FMooseX-StrictConstructor.git diff --git a/lib/MooseX/StrictConstructor/Trait/Class.pm b/lib/MooseX/StrictConstructor/Trait/Class.pm index 1bfb0f5..579b6c2 100644 --- a/lib/MooseX/StrictConstructor/Trait/Class.pm +++ b/lib/MooseX/StrictConstructor/Trait/Class.pm @@ -5,7 +5,6 @@ use Moose::Role; use namespace::autoclean; use B (); -use Carp (); around '_inline_BUILDALL' => sub { my $orig = shift; @@ -25,9 +24,22 @@ around '_inline_BUILDALL' => sub { 'my %attrs = (' . ( join ' ', @attrs ) . ');', 'my @bad = sort grep { !$attrs{$_} } keys %{ $params };', 'if (@bad) {', - 'Carp::confess "Found unknown attribute(s) passed to the constructor: @bad";', + 'Moose->throw_error("Found unknown attribute(s) passed to the constructor: @bad");', '}', ); +} if $Moose::VERSION >= 1.9900; + +# If the base class role is applied first, and then a superclass is added, we +# lose the role. +after superclasses => sub { + my $self = shift; + + return unless @_; + + Moose::Util::MetaRole::apply_base_class_roles( + for => $self->name(), + roles => ['MooseX::StrictConstructor::Role::Object'], + ); }; 1;