use Sub::Name 'subname';
use overload ();
-our $VERSION = '0.16';
+our $VERSION = '0.18';
our $AUTHORITY = 'cpan:STEVAN';
use Moose::Meta::Method::Accessor;
elsif (exists $options->{does}) {
# allow for anon-subtypes here ...
if (blessed($options->{does}) && $options->{does}->isa('Moose::Meta::TypeConstraint')) {
- $options->{type_constraint} = $options->{isa};
+ $options->{type_constraint} = $options->{does};
}
else {
$options->{type_constraint} = Moose::Util::TypeConstraints::find_or_create_type_constraint(
$options->{does} => {
parent => Moose::Util::TypeConstraints::find_type_constraint('Role'),
- constraint => sub { $_[0]->does($options->{does}) }
+ constraint => sub {
+ Moose::Util::does_role($_[0], $options->{does})
+ }
}
);
}
my $val;
my $value_is_set;
- if (exists $params->{$init_arg}) {
+ if ( defined($init_arg) and exists $params->{$init_arg}) {
$val = $params->{$init_arg};
$value_is_set = 1;
}
$type_constraint->name .
") with '" .
(defined $val
- ? (blessed($val) && overload::Overloaded($val)
- ? overload::StrVal($val)
- : $val)
+ ? overload::StrVal($val)
: 'undef') .
"'";
}
if ($self->should_coerce) {
$value = $type_constraint->coerce($value);
}
- defined($type_constraint->_compiled_type_constraint->($value))
+ $type_constraint->_compiled_type_constraint->($value)
|| confess "Attribute ($attr_name) does not pass the type constraint ("
. $type_constraint->name
. ") with "
. (defined($value)
- ? ("'" .
- (blessed($value) && overload::Overloaded($value)
- ? overload::StrVal($value)
- : $value)
- . "'")
+ ? ("'" . overload::StrVal($value) . "'")
: "undef")
if defined($value);
}
$associated_class->add_method($handle => subname $name, sub {
my $proxy = (shift)->$accessor();
@_ = ($proxy, @_);
+ (defined $proxy)
+ || confess "Cannot delegate $handle to $method_to_call because " .
+ "the value of " . $self->name . " is not defined";
goto &{ $proxy->can($method_to_call) || return };
});
}