my @traits;
if(my $traits_ref = delete $args->{traits}){
- for (my $i = 0; $i < @{$traits_ref}; $i++) {
- my $trait = Mouse::Util::resolve_metaclass_alias(Attribute => $traits_ref->[$i], trait => 1);
+ local $@;
+ eval{
+ for (my $i = 0; $i < @{$traits_ref}; $i++) {
+ my $trait = Mouse::Util::resolve_metaclass_alias(Attribute => $traits_ref->[$i], trait => 1);
- next if $class->does($trait);
+ next if $class->does($trait);
- push @traits, $trait;
+ push @traits, $trait;
- # are there options?
- push @traits, $traits_ref->[++$i]
- if ref($traits_ref->[$i+1]);
- }
+ # are there options?
+ push @traits, $traits_ref->[++$i]
+ if ref($traits_ref->[$i+1]);
+ }
+ };
+ warn "Fatal error in traits: $@" if _MOUSE_VERBOSE;
if (@traits) {
$class = Mouse::Meta::Class->create_anon_class(
return %args;
}
-sub create {
+sub create { # DEPRECATED
my ($self, $class, $name, %args) = @_;
Carp::cluck("$self->create has been deprecated."
my($self, $value, $instance) = @_;
my $type_constraint = $self->{type_constraint};
-
- return $value if !$type_constraint;
+ return $value if !defined $type_constraint;
if ($self->should_coerce && $type_constraint->has_coercion) {
$value = $type_constraint->coerce($value);
}
- return $value if $type_constraint->check($value);
-
$self->verify_against_type_constraint($value);
return $value;
my ($self, $value) = @_;
my $type_constraint = $self->{type_constraint};
- return 1 if !$type_constraint;;
+ return 1 if !$type_constraint;
return 1 if $type_constraint->check($value);
$self->verify_type_constraint_error($self->name, $value, $type_constraint);
sub verify_type_constraint_error {
my($self, $name, $value, $type) = @_;
- $self->throw_error("Attribute ($name) does not pass the type constraint because: " . $type->get_message($value));
+ $self->throw_error("Attribute ($name) does not pass the type constraint because: "
+ . $type->get_message($value));
}
sub coerce_constraint { # DEPRECATED
Mouse::Meta::Attribute - The Mouse attribute metaclass
+=head1 VERSION
+
+This document describes Mouse version 0.39
+
=head1 METHODS
=head2 C<< new(%options) -> Mouse::Meta::Attribute >>