Add compute_all_applicable_attributes
[gitmo/Mouse.git] / lib / Mouse / Object.pm
index 70ad475..bec6519 100644 (file)
@@ -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 }) {
@@ -74,7 +85,7 @@ sub BUILDALL {
 
     no strict 'refs';
 
-    for my $class ($self->meta->linearized_isa) {
+    for my $class (reverse $self->meta->linearized_isa) {
         my $code = *{ $class . '::BUILD' }{CODE}
             or next;
         $code->($self, @_);