X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FObject.pm;h=6a2d4721a6d66d84afebf5e4c10be069d8414715;hb=d26c82ab01d405ba41f1c28cdd2f2c8ffa215de1;hp=6f38a9853e6efb931be480c942e1e5334e4819c5;hpb=b7ef2be4b4b814c7ef52b96cc33e7fb4581428ba;p=gitmo%2FMoose.git diff --git a/lib/Moose/Object.pm b/lib/Moose/Object.pm index 6f38a98..6a2d472 100644 --- a/lib/Moose/Object.pm +++ b/lib/Moose/Object.pm @@ -4,6 +4,7 @@ package Moose::Object; use strict; use warnings; +use Carp (); use Devel::GlobalDestruction (); use MRO::Compat (); use Scalar::Util (); @@ -12,21 +13,17 @@ use Try::Tiny (); use if ( not our $__mx_is_compiled ), 'Moose::Meta::Class'; use if ( not our $__mx_is_compiled ), metaclass => 'Moose::Meta::Class'; -our $VERSION = '0.95'; +our $VERSION = '1.17'; $VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; 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 { @@ -39,6 +36,12 @@ sub BUILDARGS { } return { %{ $_[0] } }; } + elsif ( @_ % 2 ) { + Carp::carp( + "The new() method for $class expects a hash reference or a key/value list." + . " You passed an odd number of arguments" ); + return { @_, undef }; + } else { return {@_}; }