<span class="highlight">handles => { 'blog_host' => 'host' },</span>
);
-<span class="highlight">$person->blog_host;</span>
-# really calls $person->blog_uri->host</code></pre>
+<span class="highlight">$person->blog_host;</span>
+# really calls $person->blog_uri->host</code></pre>
</div>
<div class="slide">
<li>Calls <code>Person->BUILDARGS(@_)</code> to turn <code>@_</code> into a hashref</li>
<li>Blesses a reference</li>
<li>Populates attributes based on the hashref from #1</li>
- <li>Calls <code>$new_object->BUILDALL($constructor_args)</code>
+ <li>Calls <code>$new_object->BUILDALL($constructor_args)</code>
<br />... which calls all <code>BUILD</code> methods</li>
<li>Returns the object</li>
</ol>
use Moose;
# true
-Person->can('extends');</code></pre>
+Person->can('extends');</code></pre>
<ul>
<li>Not very hygienic</li>
<span class="highlight">no Moose;</span>
# false
-Person->can('extends');</code></pre>
+Person->can('extends');</code></pre>
</div>
<div class="slide">
...
# false
-Person->can('extends');</code></pre>
+Person->can('extends');</code></pre>
</div>
<div class="slide">
<pre><code>package Person;
use Moose;
-<span class="highlight">__PACKAGE__->meta->make_immutable;</span></code></pre>
+<span class="highlight">__PACKAGE__->meta->make_immutable;</span></code></pre>
</div>
<div class="slide">
<span class="delete">with 'Printable';</span>
-<span class="highlight">die '...' unless __PACKAGE__->can('as_string');
+<span class="highlight">die '...' unless __PACKAGE__->can('as_string');
has has_been_printed => ( is => 'rw' );
sub break {
my $self = shift;
- $self->break_it_down;
+ $self->break_it_down;
if ( rand(1) < 0.5 ) {
- $self->break_bone;
+ $self->break_bone;
}
}</code></pre>
</div>
sub is_equal {
my $self = shift;
- return $self->compare(@_) == 0;
+ return $self->compare(@_) == 0;
}</code></pre>
</div>
# Satisfies the Comparable role
sub compare { ... }
-Integer->does('TestsEquality'); # true
-Integer->does('Comparable'); # also true!</code></pre>
+Integer->does('TestsEquality'); # true
+Integer->does('Comparable'); # also true!</code></pre>
</div>
<div class="slide">
<pre><code>use Moose::Util qw( apply_all_roles );
-my $fragile_person = Person->new( ... );
+my $fragile_person = Person->new( ... );
apply_all_roles( $fragile_person,
'IsFragile' );</code></pre>
<span class="current incremental">required => 1,</span>
);
-<span class="incremental">Person->new( first_name => undef ); # ok
-Person->new(); # kaboom</span></code></pre>
+<span class="incremental">Person->new( first_name => undef ); # ok
+Person->new(); # kaboom</span></code></pre>
</div>
<div class="slide">
<span class="highlight">init_arg => 'foot_size',</span>
);
-Person->new( <span class="wrong">shoe_size => 13</span> );
+Person->new( <span class="wrong">shoe_size => 13</span> );
my $person =
- Person->new( <span class="right">foot_size => 13</span> );
-print $person->shoe_size;</code></pre>
+ Person->new( <span class="right">foot_size => 13</span> );
+print $person->shoe_size;</code></pre>
</div>
<div class="slide">
<span class="highlight">init_arg => undef,</span>
);
-Person->new( <span class="wrong">shoes => Shoes->new</span> );</code></pre>
+Person->new( <span class="wrong">shoes => Shoes->new</span> );</code></pre>
</div>
<div class="slide">
$self->$orig(
$self->_munge_insert(@_) );
- $new_user->_assign_uri;
+ $new_user->_assign_uri;
return $new_user;
};</code></pre>
</div>
use App::CLI;
-<span class="highlight">App::CLI->new_with_options()</span>->run();</code></pre>
+<span class="highlight">App::CLI->new_with_options()</span>->run();</code></pre>
<pre>$ myapp-cli \
--file foo \