X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=moose-class%2Fslides%2Findex.html;h=72e8bbedbfcb85a3b5b06ff61c5b9996dc1caa43;hb=88ba73cb2747fd9eb409a0ce9e22188d4ecec76b;hp=fa619d8163019dcb8ef092cdac999adac54a76f5;hpb=fb6113ca13b6f433a4f047e91ac39b554276baf0;p=gitmo%2Fmoose-presentations.git diff --git a/moose-class/slides/index.html b/moose-class/slides/index.html index fa619d8..72e8bbe 100644 --- a/moose-class/slides/index.html +++ b/moose-class/slides/index.html @@ -52,7 +52,7 @@ img#me05 {top: 43px;left: 36px;}

Introduction to Moose

-

Dave Rolsky +

Dave Rolsky

@@ -71,8 +71,8 @@ img#me05 {top: 43px;left: 36px;}
@@ -155,7 +155,7 @@ img#me05 {top: 43px;left: 36px;}
package Person;
 use Moose;
 
-has first_name => ( is => 'rw' );
+has first_name => ( is => 'ro' ); @@ -968,6 +968,7 @@ sub BUILD { @@ -1053,13 +1054,13 @@ use Moose; extends 'Person'; -override work => sub { +override work => sub { my $self = shift; die "Pay me first" unless $self->got_paid; - super(); -}; + super(); +};
@@ -1068,7 +1069,7 @@ use Moose;
@@ -1235,6 +1236,8 @@ use Moose; # perl install-moose (if needed) +## Read the instructions in t/01-classes.t + # perl bin/prove -lv t/01-classes.t # edit lib/Person.pm and lib/Employee.pm @@ -1306,23 +1309,25 @@ sub print {
package Person;
 use Moose;
 
-with 'HasPermissions';
+with 'Printable';

Classes Consume Roles

-
my $person = Person->new(
+
package Person;
+
+sub as_string { $_[0]->first_name() }
+
+...
+
+my $person = Person->new(
     first_name   => 'Kenichi',
     last_name    => 'Asai',
     access_level => 42,
 );
 
-print $person->full_name
-    . ' has '
-    . $person->can_access(42)
-        ? 'great power'
-        : 'little power';
+$person->print();
@@ -1339,7 +1344,9 @@ print $person->full_name
package Person;
 use Moose;
 
-with 'Printable';
+with 'Printable'; + +sub as_string { $_[0]->first_name() }
@@ -1350,6 +1357,8 @@ use Moose; with 'Printable'; +sub as_string { $_[0]->first_name() } + has has_been_printed => ( is => 'rw' ); sub print { @@ -1655,8 +1664,6 @@ requires 'compare';

Real Examples

-

What if I Want to Share?

- -
package Person;
-use Moose;
-
-my $highlander_bank =
-    Bank->new(
-        name => 'Clan MacLeod Trust' );
-
-has bank => (
-    is      => 'rw',
-    default => sub { $highlander_bank },
-);
-
- -

Builder

@@ -2406,62 +2390,6 @@ around run => sub {
-

Augment and Inner

- - -
- -
-

Augment and Inner

- -
package Document;
-
-sub xml { '<doc>' . inner() . '</doc>' }
-
-package Report;
-extends 'Document';
-augment xml =>
-    sub { my $self = shift;
-          $self->title() . inner() . $self->summary() };
-
-package TPSReport;
-extends 'Report';
-augment xml =>
-    sub { my $self = shift;
-          $self->tps_xml() . inner() };
-
- -
-

Augment and Inner

- - -
- -
-

Augment and Inner Usage

- - -
- -

Method Modifiers Summary

-

Method Modifiers Summary

- - -
- -

Questions?

@@ -2587,15 +2501,12 @@ Item

Bool

True

-
1
-924.1
-'true'
-{}
+
1

False

0
-0.0
 '0'
+''
 undef