package Mouse::Object;
use strict;
use warnings;
-use MRO::Compat;
-use Scalar::Util qw/blessed weaken/;
+use Mouse::Util qw/weaken/;
use Carp 'confess';
sub new {
my $default;
if (defined($from) && exists($args->{$from})) {
+ $args->{$from} = $attribute->coerce_constraint($args->{$from})
+ if $attribute->should_coerce;
$attribute->verify_type_constraint($args->{$from})
if $attribute->has_type_constraint;
? $default->()
: $default;
+ $value = $attribute->coerce_constraint($value)
+ if $attribute->should_coerce;
$attribute->verify_type_constraint($value)
if $attribute->has_type_constraint;
# short circuit
return unless $self->can('BUILD');
- no strict 'refs';
-
for my $class (reverse $self->meta->linearized_isa) {
+ no strict 'refs';
+ no warnings 'once';
my $code = *{ $class . '::BUILD' }{CODE}
or next;
$code->($self, @_);
You may put any business logic initialization in BUILD methods. You don't
need to redispatch or return any specific value.
+=head2 BUILDARGS
+
+Lets you override the arguments that C<new> takes. Return a hashref of
+parameters.
+
=head2 DEMOLISHALL
Calls L</DEMOLISH> on each class in the class hierarchy. This is called at