X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FMeta%2FAttribute.pm;h=627776965677b8551e60e8cbca39e91f8ba6e2a8;hb=refs%2Ftags%2F0.66;hp=88d3756f608399f0aa58e6e1e5e64c6e95116ab6;hpb=2b86e02bf0ee5f21387989c0af89dc7feec412e3;p=gitmo%2FMoose.git diff --git a/lib/Moose/Meta/Attribute.pm b/lib/Moose/Meta/Attribute.pm index 88d3756..6277769 100644 --- a/lib/Moose/Meta/Attribute.pm +++ b/lib/Moose/Meta/Attribute.pm @@ -7,7 +7,7 @@ use warnings; use Scalar::Util 'blessed', 'weaken'; use overload (); -our $VERSION = '0.63'; +our $VERSION = '0.66'; our $AUTHORITY = 'cpan:STEVAN'; use Moose::Meta::Method::Accessor; @@ -145,6 +145,7 @@ my @legal_options_for_inheritance = qw( default coerce required documentation lazy handles builder type_constraint + definition_context ); sub legal_options_for_inheritance { @legal_options_for_inheritance } @@ -411,7 +412,7 @@ sub initialize_instance_slot { if ($self->should_coerce && $type_constraint->has_coercion) { $val = $type_constraint->coerce($val); } - $self->check_type_constraint($val, instance => $instance); + $self->verify_against_type_constraint($val, instance => $instance); } $self->set_initial_value($instance, $val); @@ -463,7 +464,7 @@ sub _set_initial_slot_value { if ($type_constraint) { $val = $type_constraint->coerce($val) if $can_coerce; - $self->check_type_constraint($val, object => $instance); + $self->verify_against_type_constraint($val, object => $instance); } $meta_instance->set_slot_value($instance, $slot_name, $val); }; @@ -527,7 +528,7 @@ sub get_value { my $type_constraint = $self->type_constraint; $value = $type_constraint->coerce($value) if ($self->should_coerce); - $self->check_type_constraint($value); + $self->verify_against_type_constraint($value); } $self->set_initial_value($instance, $value); } @@ -704,6 +705,8 @@ sub _get_delegate_method_list { } } +sub delegation_metaclass { 'Moose::Meta::Method::Delegation' } + sub _make_delegation_method { my ( $self, $handle_name, $method_to_call ) = @_; @@ -712,7 +715,7 @@ sub _make_delegation_method { $method_body = $method_to_call if 'CODE' eq ref($method_to_call); - return Moose::Meta::Method::Delegation->new( + return $self->delegation_metaclass->new( name => $handle_name, package_name => $self->associated_class->name, attribute => $self, @@ -720,7 +723,7 @@ sub _make_delegation_method { ); } -sub check_type_constraint { +sub verify_against_type_constraint { my $self = shift; my $val = shift; @@ -786,6 +789,8 @@ will behave just as L does. =item B +=item B + =item B =item B @@ -850,9 +855,9 @@ A read-only accessor for this meta-attribute's type constraint. For more information on what you can do with this, see the documentation for L. -=item B +=item B -Confirms that the given value is valid under this attribute's type +Verifies that the given value is valid under this attribute's type constraint, otherwise throws an error. =item B @@ -963,7 +968,7 @@ Yuval Kogman Enothingmuch@woobling.comE =head1 COPYRIGHT AND LICENSE -Copyright 2006-2008 by Infinity Interactive, Inc. +Copyright 2006-2009 by Infinity Interactive, Inc. L