use strict;
use warnings;
+use Scalar::Util;
+
use if ( not our $__mx_is_compiled ), 'Moose::Meta::Class';
use if ( not our $__mx_is_compiled ), metaclass => 'Moose::Meta::Class';
sub new {
my $class = shift;
+
my $params = $class->BUILDARGS(@_);
- my $self = Class::MOP::Class->initialize($class)->new_object($params);
+
+ # We want to support passing $self->new, but initialize
+ # takes only an unblessed class name
+ my $real_class = Scalar::Util::blessed($class) || $class;
+ my $self = Class::MOP::Class->initialize($real_class)->new_object($params);
+
$self->BUILDALL($params);
+
return $self;
}