aboutsummaryrefslogtreecommitdiffstats
path: root/lib/MooseX/AlwaysCoerce.pm
diff options
context:
space:
mode:
authorRafael Kitover <rkitover@cpan.org>2010-08-04 23:43:31 -0400
committerRafael Kitover <rkitover@cpan.org>2010-08-04 23:43:31 -0400
commitbb7cca58bd0aeb53796d1e058082f04077c630cc (patch)
treedb48f46ac0157ef5f7bd09f06fb7e938ebd2d212 /lib/MooseX/AlwaysCoerce.pm
parent0a64dac6a3376cc92b81b708dbd56f5cc675d050 (diff)
downloadmx-alwayscoerce-0.09.tar.gz
mx-alwayscoerce-0.09.zip
support attributes without isa, better tests, release0.09
Diffstat (limited to 'lib/MooseX/AlwaysCoerce.pm')
-rw-r--r--lib/MooseX/AlwaysCoerce.pm15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/MooseX/AlwaysCoerce.pm b/lib/MooseX/AlwaysCoerce.pm
index 51e2f2e..66bb1e9 100644
--- a/lib/MooseX/AlwaysCoerce.pm
+++ b/lib/MooseX/AlwaysCoerce.pm
@@ -18,11 +18,11 @@ MooseX::AlwaysCoerce - Automatically enable coercions for Moose attributes
=head1 VERSION
-Version 0.08
+Version 0.09
=cut
-our $VERSION = '0.08';
+our $VERSION = '0.09';
=head1 SYNOPSIS
@@ -62,7 +62,7 @@ Use C<< coerce => 0 >> to disable a coercion explicitly.
return $current_val if defined $current_val;
- return 1 if $self->type_constraint->has_coercion;
+ return 1 if $self->type_constraint && $self->type_constraint->has_coercion;
return 0;
};
@@ -77,10 +77,10 @@ Use C<< coerce => 0 >> to disable a coercion explicitly.
my $self = shift;
my ($what, %opts) = @_;
- return unless exists $opts{isa};
-
- my $type = Moose::Util::TypeConstraints::find_or_parse_type_constraint($opts{isa});
- $opts{coerce} = 1 if not exists $opts{coerce} and $type->has_coercion;
+ if (exists $opts{isa}) {
+ my $type = Moose::Util::TypeConstraints::find_or_parse_type_constraint($opts{isa});
+ $opts{coerce} = 1 if not exists $opts{coerce} and $type->has_coercion;
+ }
$self->$next($what, %opts);
};
@@ -167,3 +167,4 @@ under the same terms as Perl itself.
=cut
1; # End of MooseX::AlwaysCoerce
+# vim:et sts=4 sw=4 tw=0: