From: Shawn M Moore Date: Wed, 11 Jun 2008 11:03:27 +0000 (+0000) Subject: Add support for ->new({...}) X-Git-Tag: 0.04~23 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=da4cb9138f328819fed3e779b4b03cdd9294ce24;p=gitmo%2FMouse.git Add support for ->new({...}) --- diff --git a/lib/Mouse/Object.pm b/lib/Mouse/Object.pm index 265787a..bec6519 100644 --- a/lib/Mouse/Object.pm +++ b/lib/Mouse/Object.pm @@ -9,7 +9,18 @@ use Carp 'confess'; sub new { my $class = shift; - my %args = @_; + my %args; + if (scalar @_ == 1) { + if (defined $_[0]) { + (ref($_[0]) eq 'HASH') + || confess "Single parameters to new() must be a HASH ref"; + %args = %{$_[0]}; + } + } + else { + %args = @_; + } + my $instance = bless {}, $class; for my $attribute (values %{ $class->meta->get_attribute_map }) {