carried BUILDARGS in Person.pm from exercise 1 forward through the later answer class...
[gitmo/moose-presentations.git] / moose-class / exercises / answers / 02-roles / Person.pm
index e3b718a..ca3104a 100644 (file)
@@ -7,6 +7,20 @@ with 'Printable', 'HasAccount';
 has first_name => ( is => 'rw' );
 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;