moved back up into Moose::Meta::Class and Moose::Meta::Role individually
(through the Class::MOP::Mixin::HasMethods mixin) (doy).
+ * BUILDALL is now called by Moose::Meta::Class::new_object, rather than by
+ Moose::Object::new. (doy)
+
[BUG FIXES]
* Fix has '+attr' in Roles to explode immediately, rather than when the role
'MooseX::Attribute::Prototype' => '0.10',
'MooseX::ClassAttribute' => '0.09',
'MooseX::MethodAttributes' => '0.18',
- 'MooseX::NonMoose' => '0.05',
+ 'MooseX::NonMoose' => '0.07',
'MooseX::Params::Validate' => '0.05',
'MooseX::Role::Cmd' => '0.06',
'MooseX::Role::WithOverloading' => '0.04',
it documented here, or think we missed an important feature, please
send us a patch.
+=over 4
+
+=item L<Moose::Object/BUILD> methods are now called when calling C<new_object>
+
+Previously, C<BUILD> methods would only be called from C<Moose::Object::new>,
+but now they are also called when constructing an object via
+C<Moose::Meta::Class::new_object>. C<BUILD> methods are an inherent part of the
+object construction process, and this should make C<< $meta->new_object >>
+actually usable without forcing people to use C<< $meta->name->new >>.
+
+=back
+
=head1 1.02
=over 4
);
}
+ $self->BUILDALL($params) if $self->can('BUILDALL');
+
return $self;
}
sub new {
my $class = shift;
-
- my $params = $class->BUILDARGS(@_);
-
my $real_class = Scalar::Util::blessed($class) || $class;
- my $self = Class::MOP::Class->initialize($real_class)->new_object($params);
- $self->BUILDALL($params);
+ my $params = $real_class->BUILDARGS(@_);
- return $self;
+ return Class::MOP::Class->initialize($real_class)->new_object($params);
}
sub BUILDARGS {
--- /dev/null
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More;
+
+my $called;
+{
+ package Foo;
+ use Moose;
+
+ sub BUILD { $called++ }
+}
+
+Foo->new;
+is($called, 1, "BUILD called from ->new");
+$called = 0;
+Foo->meta->new_object;
+is($called, 1, "BUILD called from ->meta->new_object");
+
+done_testing;