From: Karen Etheridge Date: Thu, 7 Apr 2011 16:42:28 +0000 (-0700) Subject: better check for if add_class_attribute is present. X-Git-Tag: v0.17~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMooseX-AlwaysCoerce.git;a=commitdiff_plain;h=620f60fd8297bf2ccfde2f391f9ebb63a74af18b better check for if add_class_attribute is present. --- 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(