X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FAlwaysCoerce.pm;h=5ab21f19481b3cd373b324b2e6f5470e1a465e48;hb=620f60fd8297bf2ccfde2f391f9ebb63a74af18b;hp=8cb3831f7b6a7bc828a91ba2cb11762e919ea595;hpb=418d177d4f460b579609d31d2ae1246bf7093c38;p=gitmo%2FMooseX-AlwaysCoerce.git diff --git a/lib/MooseX/AlwaysCoerce.pm b/lib/MooseX/AlwaysCoerce.pm index 8cb3831..5ab21f1 100644 --- a/lib/MooseX/AlwaysCoerce.pm +++ b/lib/MooseX/AlwaysCoerce.pm @@ -71,9 +71,6 @@ Use C<< coerce => 0 >> to disable a coercion explicitly. use Moose::Role; use Moose::Util::TypeConstraints; - # MooseX::ClassAttribute is not always present in the consuming class - sub add_class_attribute { } - around add_class_attribute => sub { my $next = shift; my $self = shift; @@ -85,7 +82,9 @@ Use C<< coerce => 0 >> to disable a coercion explicitly. } $self->$next($what, %opts); - }; + } + # MooseX::ClassAttribute is not always present in the consuming class/role + if __PACKAGE__->meta->has_method('add_class_attribute'); } my (undef, undef, $init_meta) = Moose::Exporter->build_import_methods(