From: 大沢 和宏 Date: Tue, 2 Dec 2008 12:03:42 +0000 (+0000) Subject: fixed bug, problem of coercer feature is moose compat X-Git-Tag: 0.19~136^2~81 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=32af3489ac653966a8ec8df63bec882585c73676;p=gitmo%2FMouse.git fixed bug, problem of coercer feature is moose compat --- diff --git a/lib/Mouse/Meta/Attribute.pm b/lib/Mouse/Meta/Attribute.pm index 5a43c4d..e0473a9 100644 --- a/lib/Mouse/Meta/Attribute.pm +++ b/lib/Mouse/Meta/Attribute.pm @@ -36,7 +36,7 @@ sub type_constraint { $_[0]->{type_constraint} } sub trigger { $_[0]->{trigger} } sub builder { $_[0]->{builder} } sub should_auto_deref { $_[0]->{auto_deref} } -sub is_coerce { $_[0]->{is_coerce} } +sub should_coerce { $_[0]->{should_coerce} } sub has_default { exists $_[0]->{default} } sub has_predicate { exists $_[0]->{predicate} } @@ -61,15 +61,15 @@ sub inlined_name { sub generate_accessor { my $attribute = shift; - my $name = $attribute->name; - my $default = $attribute->default; - my $type = $attribute->type_constraint; - my $constraint = $attribute->find_type_constraint; - my $builder = $attribute->builder; - my $trigger = $attribute->trigger; - my $is_weak = $attribute->is_weak_ref; - my $should_deref = $attribute->should_auto_deref; - my $is_coerce = $attribute->is_coerce; + my $name = $attribute->name; + my $default = $attribute->default; + my $type = $attribute->type_constraint; + my $constraint = $attribute->find_type_constraint; + my $builder = $attribute->builder; + my $trigger = $attribute->trigger; + my $is_weak = $attribute->is_weak_ref; + my $should_deref = $attribute->should_auto_deref; + my $should_coerce = $attribute->should_coerce; my $self = '$_[0]'; my $key = $attribute->inlined_name; @@ -81,7 +81,7 @@ sub generate_accessor { my $value = '$_[1]'; if ($constraint) { - if ($is_coerce) { + if ($should_coerce) { $accessor .= $value.' = $attribute->coerce_constraint('.$value.');'; } $accessor .= 'local $_ = '.$value.';'; @@ -197,7 +197,7 @@ sub create { %args = $self->canonicalize_args($name, %args); $self->validate_args($name, \%args); - $args{is_coerce} = delete $args{coerce} + $args{should_coerce} = delete $args{coerce} if exists $args{coerce}; $args{type_constraint} = delete $args{isa} diff --git a/lib/Mouse/Object.pm b/lib/Mouse/Object.pm index 0c57594..a49d08c 100644 --- a/lib/Mouse/Object.pm +++ b/lib/Mouse/Object.pm @@ -20,7 +20,7 @@ sub new { if (defined($from) && exists($args->{$from})) { $args->{$from} = $attribute->coerce_constraint($args->{$from}) - if $attribute->is_coerce; + if $attribute->should_coerce; $attribute->verify_type_constraint($args->{$from}) if $attribute->has_type_constraint; @@ -45,7 +45,7 @@ sub new { : $default; $value = $attribute->coerce_constraint($value) - if $attribute->is_coerce; + if $attribute->should_coerce; $attribute->verify_type_constraint($value) if $attribute->has_type_constraint;