X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=moose-class%2Fslides%2Findex.html;h=70bdfc651c96000d181fa3e1664ae8a5fe5a06b6;hb=c1d605dbbaf56eed6436ec8821158c509b8210fe;hp=4dca048685b366cc750cf4e2fe9e7d76e7d35598;hpb=7205c6ef463bf6cce623bf72646fbe5915023115;p=gitmo%2Fmoose-presentations.git diff --git a/moose-class/slides/index.html b/moose-class/slides/index.html index 4dca048..70bdfc6 100644 --- a/moose-class/slides/index.html +++ b/moose-class/slides/index.html @@ -40,7 +40,7 @@ img#me05 {top: 43px;left: 36px;} @@ -885,10 +898,9 @@ use Moose; sub BUILDARGS { my $class = shift; - if ( @_ == 1 && ! ref $_[0] ) { + if ( @_ == 1 && ! ref $_[0] ) { return { ssn => $_[0] }; } - return $class->SUPER::BUILDARGS(@_); } @@ -940,7 +952,7 @@ sub BUILD {
-

The Object is Oqaque

+

The Object is Opaque

@@ -1127,6 +1142,7 @@ Person->can('extends'); @@ -1187,12 +1203,15 @@ use Moose;

Exercises

# cd exercises
-$ perl bin/prove -lv t/00-prereq.t
 
-Missing anything? Install it. (see tarballs/)
+# perl bin/prove -lv t/00-prereq.t
+
+# perl install-moose (if needed)
 
 # perl bin/prove -lv t/01-classes.t
 
+# edit lib/Person.pm and lib/Employee.pm
+
 Iterate til this passes all its tests
@@ -1210,11 +1229,10 @@ Iterate til this passes all its tests
-

Roles Can Have State and Behavior

+

Roles - State and Behavior

package HasPermissions;
 use Moose::Role;
-
 # state
 has access_level => ( is => 'rw' );
 
@@ -1223,7 +1241,8 @@ sub can_access {
     my $self     = shift;
     my $required = shift;
 
-    return $self->access_level >= $required;
+    return $self->access_level
+             >= $required;
 }
@@ -1267,8 +1286,8 @@ with 'HasPermissions';

Classes Consume Roles

my $person = Person->new(
-    first_name => 'Kenichi',
-    last_name => 'Asai',
+    first_name   => 'Kenichi',
+    last_name    => 'Asai',
     access_level => 42,
 );
 
@@ -1324,7 +1343,7 @@ sub print {
 
 # or ...
 
-if ( Person->meta->does('Printable') ) { ... }
+Person->meta->does('Printable') @@ -1390,10 +1409,10 @@ use Moose; use Moose; with 'IsFragile' => - { alias => + { -alias => { break => 'break_bone' } }, 'CanBreakdance' => - { alias => + { -alias => { break => 'break_it_down' } };