X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=moose-class%2Fslides%2Findex.html;h=e1e33504393d994cac32ed05128268abcc81166c;hb=6b24100035035acc3bb86df2c45a2463d09bf3cf;hp=11028ceab45f016effed5fdb8a4406868c2d68db;hpb=659a35cda3c2226ac9b5e79a931e5f1a63539b39;p=gitmo%2Fmoose-presentations.git
diff --git a/moose-class/slides/index.html b/moose-class/slides/index.html
index 11028ce..e1e3350 100644
--- a/moose-class/slides/index.html
+++ b/moose-class/slides/index.html
@@ -218,7 +218,7 @@ use Moose;
- AKA advice
- "Before foo(), do this first"
- - "Do this after foo()
+ - "Do this after foo()"
- "Put this code around foo()"
@@ -300,8 +300,8 @@ has blog_uri => (
handles => { 'blog_host' => 'host' },
);
-$person->blog_host;
-# really calls $person->blog_uri->host
+$person->blog_host;
+# really calls $person->blog_uri->host
@@ -955,7 +955,7 @@ sub BUILD {
Calls Person->BUILDARGS(@_)
to turn @_
into a hashref
Blesses a reference
Populates attributes based on the hashref from #1
-
Calls $new_object->BUILDALL($constructor_args)
+ Calls $new_object->BUILDALL($constructor_args)
... which calls all BUILD
methods
Returns the object
@@ -1127,7 +1127,7 @@ print $person->first_name; # Dave
use Moose;
# true
-Person->can('extends');
+Person->can('extends');
- Not very hygienic
@@ -1142,10 +1142,23 @@ use Moose;
...
-no Moose;
+no Moose;
# false
-Person->can('extends');
+Person->can('extends');
+
+
+
+
Cleaning Up Moose Droppings
+
+
package Person;
+use namespace::autoclean;
+use Moose;
+
+...
+
+# false
+Person->can('extends');
@@ -1163,13 +1176,13 @@ Person->can('extends');
Immutability
- - Stevan's Incantation of Fleet-Footedness
+ - Stevan's Incantation of Fleet-Footedness
package Person;
use Moose;
-__PACKAGE__->meta->make_immutable;
+
__PACKAGE__->meta->make_immutable;
@@ -1355,7 +1368,7 @@ sub print {
# or ...
-Person->meta->does('Printable')
+Person->meta->does_role('Printable')
@@ -1458,9 +1471,9 @@ use Moose;
sub break {
my $self = shift;
- $self->break_it_down;
+ $self->break_it_down;
if ( rand(1) < 0.5 ) {
- $self->break_bone;
+ $self->break_bone;
}
}
@@ -1477,7 +1490,7 @@ sub break {
-
Hot Role-on-Role Action
+
Roles With Roles
package Comparable;
use Moose::Role;
@@ -1486,7 +1499,7 @@ requires 'compare';
-
Hot Role-on-Role Action
+
Roles With Roles
package TestsEquality;
use Moose::Role;
@@ -1495,7 +1508,7 @@ with 'Comparable';
sub is_equal {
my $self = shift;
- return $self->compare(@_) == 0;
+ return $self->compare(@_) == 0;
}
@@ -1510,8 +1523,8 @@ with 'TestsEquality';
# Satisfies the Comparable role
sub compare { ... }
-Integer->does('TestsEquality'); # true
-Integer->does('Comparable'); # also true!
+Integer->does('TestsEquality'); # true
+Integer->does('Comparable'); # also true!
@@ -1533,11 +1546,11 @@ with 'HasSubProcess';
Delayed Conflict
-
package StateOfTexas;
+ package SysadminAssassin;
with 'Killer';
- StateOfTexas
must implement its own execute
+ SysadminAssassin
must implement its own execute
- But loading the
Killer
role by itself does not cause an error
@@ -1618,7 +1631,7 @@ has [ 'left', 'right' ] => (
use Moose::Util qw( apply_all_roles );
-my $fragile_person = Person->new( ... );
+my $fragile_person = Person->new( ... );
apply_all_roles( $fragile_person,
'IsFragile' );
@@ -1774,8 +1787,8 @@ has first_name => (
required => 1,
);
-
Person->new( first_name => undef ); # ok
-Person->new(); # kaboom
+
Person->new( first_name => undef ); # ok
+Person->new(); # kaboom
@@ -2045,11 +2058,11 @@ has shoe_size => (
init_arg => 'foot_size',
);
-Person->new( shoe_size => 13 );
+Person->new( shoe_size => 13 );
my $person =
- Person->new( foot_size => 13 );
-print $person->shoe_size;
+ Person->new( foot_size => 13 );
+print $person->shoe_size;
@@ -2063,7 +2076,7 @@ has shoes => (
init_arg => undef,
);
-Person->new( shoes => Shoes->new );
+Person->new( shoes => Shoes->new );
@@ -2384,7 +2397,7 @@ after clear_password => sub {
$self->$orig(
$self->_munge_insert(@_) );
- $new_user->_assign_uri;
+ $new_user->_assign_uri;
return $new_user;
};
@@ -2595,6 +2608,7 @@ Item
Num
Int
ClassName
+ RoleName
@@ -2748,7 +2762,7 @@ class_type 'DateTime';
-subtype 'DateTime',
+subtype 'DateTime',
as 'Object',
where { $_->isa('DateTime') },
message { ... };
@@ -2763,7 +2777,7 @@ role_type 'Printable';
subtype 'Printable',
- as 'Object',
+ as 'Object',
where
{ Moose::Util::does_role(
$_, 'Printable' ) },
@@ -2796,7 +2810,7 @@ enum Color => qw( red blue green ) );
my %ok = map { $_ => 1 }
qw( red blue green );
-subtype 'Color'
+subtype 'Color'
as 'Str',
where { $ok{$_} },
message { ... };
@@ -3719,7 +3733,7 @@ sub run { ... }
use App::CLI;
-App::CLI->new_with_options()->run();
+App::CLI->new_with_options()->run();
$ myapp-cli \
--file foo \