Make tests match the order of the instructions for test 03
[gitmo/moose-presentations.git] / moose-class / exercises / answers / 03-basic-attributes / Person.pm
index db69019..c94f30c 100644 (file)
@@ -10,9 +10,29 @@ has title => (
     clearer   => 'clear_title',
 );
 
-has first_name => ( is => 'rw' );
+has first_name => (
+    is       => 'rw',
+    required => 1,
+);
+
+has last_name => (
+    is       => 'rw',
+    required => 1,
+);
 
-has last_name  => ( is => 'rw' );
+sub BUILDARGS {
+    my $class = shift;
+
+    if ( @_ == 1 && 'ARRAY' eq ref $_[0] ) {
+        return {
+            first_name => $_[0]->[0],
+            last_name  => $_[0]->[1],
+        };
+    }
+    else {
+        return $class->SUPER::BUILDARGS(@_);
+    }
+}
 
 sub full_name {
     my $self = shift;