X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=moose-class%2Fslides%2Findex.html;h=67fcb8e6b3fadea9b8573f8b39f92f7d58624414;hb=1847dd9ee8e1f995b293d12f2dc700b6f43092dc;hp=992d256381abc92e3ffbd02249933184b8c96856;hpb=1c32806a415472ca126fcba161ec8e15ed45540f;p=gitmo%2Fmoose-presentations.git diff --git a/moose-class/slides/index.html b/moose-class/slides/index.html index 992d256..67fcb8e 100644 --- a/moose-class/slides/index.html +++ b/moose-class/slides/index.html @@ -40,7 +40,7 @@ img#me05 {top: 43px;left: 36px;} @@ -284,10 +287,10 @@ use Moose; has blog_uri => ( is => 'rw', isa => 'URI', - handles => { 'blog_hostname' => 'host' }, + handles => { 'blog_host' => 'host' }, ); -$person->blog_hostname; +$person->blog_host; # really calls $person->blog_uri->host @@ -888,7 +891,6 @@ sub BUILDARGS { if ( @_ == 1 && ! ref $_[0] ) { return { ssn => $_[0] }; } - return $class->SUPER::BUILDARGS(@_); } @@ -962,6 +964,8 @@ sub BUILD {
package Employee;
@@ -1029,7 +1033,8 @@ use Moose;
 override work => sub {
     my $self = shift;
 
-    die "Pay me first" unless $self->got_paid;
+    die "Pay me first"
+        unless $self->got_paid;
     super();
 };
@@ -1127,7 +1132,7 @@ Person->can('extends'); @@ -1195,6 +1200,8 @@ use Moose; # perl bin/prove -lv t/01-classes.t +# edit lib/Person.pm and lib/Employee.pm + Iterate til this passes all its tests @@ -1212,11 +1219,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' );
 
@@ -1225,7 +1231,8 @@ sub can_access {
     my $self     = shift;
     my $required = shift;
 
-    return $self->access_level >= $required;
+    return $self->access_level
+             >= $required;
 }
@@ -1269,8 +1276,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,
 );
 
@@ -1326,7 +1333,7 @@ sub print {
 
 # or ...
 
-if ( Person->meta->does('Printable') ) { ... }
+Person->meta->does('Printable') @@ -1392,10 +1399,10 @@ use Moose; use Moose; with 'IsFragile' => - { alias => + { -alias => { break => 'break_bone' } }, 'CanBreakdance' => - { alias => + { -alias => { break => 'break_it_down' } };