diff options
author | doy <doy@tozt.net> | 2009-04-20 01:42:03 -0500 |
---|---|---|
committer | doy <doy@tozt.net> | 2009-04-20 01:42:03 -0500 |
commit | 51f11b41aef336cca76b88b3fab9e02a7980ff14 (patch) | |
tree | b7a8f5de8734de196ebc9b4200b465563b8cd7ae /lib | |
parent | 2a93aac1a9697e29b20be64cd1da7b0c9e3a2390 (diff) | |
download | moosex-nonmoose-51f11b41aef336cca76b88b3fab9e02a7980ff14.tar.gz moosex-nonmoose-51f11b41aef336cca76b88b3fab9e02a7980ff14.zip |
rewrite the _make_immutable_transformer wrapper to be more sane
Diffstat (limited to 'lib')
-rw-r--r-- | lib/MooseX/NonMoose/Meta/Role/Class.pm | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/MooseX/NonMoose/Meta/Role/Class.pm b/lib/MooseX/NonMoose/Meta/Role/Class.pm index e8524a2..9ce56db 100644 --- a/lib/MooseX/NonMoose/Meta/Role/Class.pm +++ b/lib/MooseX/NonMoose/Meta/Role/Class.pm @@ -10,11 +10,24 @@ has replace_constructor => ( around _make_immutable_transformer => sub { my $orig = shift; my $self = shift; + + # do nothing if extends was never called + return $self->$orig(@_) if !$self->replace_constructor; + + # do nothing if extends was called, but we then added a method modifier to + # the constructor (this will warn, but that's okay) + return $self->$orig(@_) + if $self->get_method('new')->isa('Class::MOP::Method::Wrapped'); + + # do nothing if we explicitly ask for the constructor to not be inlined my %args = @_; return $self->$orig(@_) if exists $args{inline_constructor} && !$args{inline_constructor}; - $args{replace_constructor} = 1 if $self->replace_constructor; - $self->$orig(%args); + + # otherwise, explicitly ask for the constructor to be replaced (to suppress + # the warning message), since this is the expected usage, and shouldn't + # cause a warning + return $self->$orig(replace_constructor => 1, @_); }; around superclasses => sub { |