X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FObject.pm;h=12ce2890e72ca2e80660f6c440a6ecb6bd470e63;hb=refs%2Ftags%2F1.25;hp=a99f069d1e14f1afe15893b0b346975ffb9e2c84;hpb=dd5eb91f3add51306c083e87705567a0ef51640d;p=gitmo%2FMoose.git diff --git a/lib/Moose/Object.pm b/lib/Moose/Object.pm index a99f069..12ce289 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.92'; +our $VERSION = '1.25'; $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 {@_}; } @@ -119,11 +122,7 @@ sub does { my $meta = Class::MOP::class_of($self); (defined $role_name) || $meta->throw_error("You must supply a role name to does()"); - foreach my $class ($meta->class_precedence_list) { - my $m = $meta->initialize($class); - return 1 - if $m->can('does_role') && $m->does_role($role_name); - } + return 1 if $meta->can('does_role') && $meta->does_role($role_name); return 0; } @@ -217,9 +216,7 @@ the maximum depth is 1, to avoid making a mess. =head1 BUGS -All complex software has bugs lurking in it, and this module is no -exception. If you find a bug please either email me, or add the bug -to cpan-RT. +See L for details on reporting bugs. =head1 AUTHOR @@ -227,7 +224,7 @@ Stevan Little Estevan@iinteractive.comE =head1 COPYRIGHT AND LICENSE -Copyright 2006-2009 by Infinity Interactive, Inc. +Copyright 2006-2010 by Infinity Interactive, Inc. L