<ul>
<li><strong>Declarative</strong> OO sugar</li>
<li>Introspectable</li>
- <li>Extensible (MooseX::* on CPAN)</li>
+ <li>Extensible (177 MooseX::* on CPAN)</li>
+ <li>Community approved (1222 downstream dependents on CPAN)</li>
</ul>
</div>
<h1>BUILDARGS</h1>
<ul>
- <li>Takes <code>@_</code>, returns a hash reference of attribute name/value pairs</li>
- <li>Accepts a hash or hashref; throws otherwise</li>
+ <li>Processes <code>new</code>'s <code>@_</code>, returns a hash reference of attribute name/value pairs</li>
+ <li>Accepts a hash or hashref; errors otherwise</li>
<li>Provide your own for other cases</li>
<li><strong>Always</strong> call <code>$class->SUPER::BUILDARGS(@_)</code> as a fallback!</li>
</ul>
<ul>
<li>Technically it's a hash reference</li>
<li><span class="wrong">If you <em>ever</em> treat it as one <strong>you are doing it wrong!</strong></span></li>
+ <li>Moose probably provides a feature to do what you need</li>
</ul>
</div>
<ul>
<li>Like <code>DESTROY</code>, but Moose makes sure all <code>DEMOLISH</code> methods in a hierarchy are called</li>
<li>Called in normal inheritance order, children to parents</li>
+ <li><em>Never</em> called by you, only by Perl itself</li>
</ul>
</div>
<ul>
<li><code>override</code> is another method modifier</li>
<li>An alternative to Perl's <code>SUPER::</code></li>
+ <li><em>Declares</em> your intent to override a method</li>
</ul>
</div>
<span class="current incremental">extends 'Person';</span>
-<span class="incremental">override</span> work => sub {
+<span class="incremental">override</span> <span class="incremental">work</span> => sub {
my $self = shift;
die "Pay me first"
<h1>Roles in Practice</h1>
<ul>
- <li>Consuming a role =~ inlining the role</li>
+ <li>Consuming a role ≈ inlining the role</li>
</ul>
</div>
<span class="incremental">with 'HasSize';
-has size => ( is => 'ro' );</span></code></pre>
+has size => ( is => 'ro' );</span></code></pre>
</div>
<div class="slide">
package Shirt;
use Moose;
-has size => ( is => 'ro' );
+has size => ( is => 'ro' );
with 'HasSize';</code></pre>
</div>
<pre><code>package Comparison;
use Moose;
-has [ 'left', 'right' ] => (
- is => 'ro',
- <span class="highlight">does => 'Comparable',</span>
+has [ 'left', 'right' ] => (
+ is => 'ro',
+ <span class="highlight">does => 'Comparable',</span>
);
</code></pre>
sub _build_bank {
my $self = shift;
return Bank->new(
- name => 'Spire FCU' );
+ name => 'Spire FCU' );
}</code></pre>
</div>
<pre><code>has shoes => (
is => 'ro',
<span class="highlight">lazy => 1,</span>
- builder => '_build_shoes',
+ builder => '_build_shoes',
);
sub _build_shoes {
<pre><code>package Person;
use Moose;
-has shoe_size => (
+has shoe_size => (
is => 'ro',
<span class="highlight">init_arg => 'foot_size',</span>
);
<pre><code>package Person;
use Moose;
-has shoes => (
+has shoes => (
is => 'ro',
<span class="highlight">init_arg => undef,</span>
);
<h1>Bool</h1>
<h2>True</h2>
- <pre><code>1
-924.1
-'true'
-{}</code></pre>
+ <pre><code>1</code></pre>
<h2>False</h2>
<pre><code>0
-0.0
'0'
+''
undef</code></pre>
<ul>
use MyApp::Types qw( ArrayOfInt );
-has transaction_history => (
- is => 'rw',
- isa => ArrayOfInt,
+has transaction_history => (
+ is => 'rw',
+ isa => ArrayOfInt,
);</code></pre>
</div>
has lungs => (
is => 'ro',
- isa => 'Lungs',
+ isa => 'Lungs',
<span class="highlight">handles => [ 'inhale', 'exhale' ],</span>
);</code></pre>
</div>
<div class="slide">
- <h1>Questions?</h1>
-</div>
-
-<div class="slide">
<h1>Exercises</h1>
<pre># cd exercises
</div>
<div class="slide">
- <h1>Questions?</h1>
-</div>
+ <h1>CYOA</h1>
-<div class="slide fake-slide0">
- <h1>The End</h1>
-</div>
-
-<div class="slide">
- <h1>More Information</h1>
+ <p>
+ If there is time, keep going ...
+ </p>
- <ul>
- <li><a href="http://moose.perl.org/">http://moose.perl.org/</a></li>
- <li><a href="http://search.cpan.org/dist/Moose/lib/Moose/Manual.pod">Moose::Manual</a> and <a href="http://search.cpan.org/dist/Moose/lib/Moose/Cookbook.pod">Moose::Cookbook</a></li>
- <li><a href="irc://irc.perl.org/#moose">irc://irc.perl.org/#moose</a></li>
- <li>mailing list - <a href="mailto:moose@perl.org">moose@perl.org</a></li>
- <li>Slides and exercises are in Moose's git repo:
- <br />
- <span style="font-size:80%; white-space: nowrap">git://jules.scsys.co.uk/gitmo/moose-presentations</span></li>
- </ul>
+ <p>
+ Otherwise, jump to slide 269 ...
+ </p>
</div>
-
<div class="slide fake-slide0">
<h1>Bonus: A Brief Tour of MooseX</h1>
</div>
<ul>
<li><strong>Not comprehensive</strong></li>
- <li>152 MooseX distributions on CPAN as of 02/02/2010</li>
+ <li>177 MooseX distributions on CPAN as of 09/21/2010</li>
<li>Some of them are crap</li>
</ul>
</div>
with HasCollection => { type => 'Int' };</code></pre>
</div>
+<div class="slide">
+ <h1>Questions?</h1>
+</div>
+
+<div class="slide">
+ <h1>Moose-using Modules</h1>
+
+ <p>
+ For further reading, a few modules which use Moose ...
+ </p>
+
+ <ul>
+ <li><a href="http://search.cpan.org/dist/Catalyst-Runtime">Catalyst</a></li>
+ <li><a href="http://search.cpan.org/dist/CHI">CHI</a></li>
+ <li><a href="http://search.cpan.org/dist/Devel-REPL">Devel::REPL</a></li>
+ <li><a href="http://search.cpan.org/dist/Email-Sender">Email::Sender</a></li>
+ <li><a href="http://search.cpan.org/dist/Fey">Fey</a></li>
+ <li><a href="http://search.cpan.org/dist/Net-Twitter">Net::Twitter</a></li>
+ </ul>
+</div>
+
+<div class="slide">
+ <h1>More Information</h1>
+
+ <ul>
+ <li><a href="http://moose.perl.org/">http://moose.perl.org/</a></li>
+ <li><a href="http://search.cpan.org/dist/Moose/lib/Moose/Manual.pod">Moose::Manual</a> and <a href="http://search.cpan.org/dist/Moose/lib/Moose/Cookbook.pod">Moose::Cookbook</a></li>
+ <li><a href="irc://irc.perl.org/#moose">irc://irc.perl.org/#moose</a></li>
+ <li>mailing list - <a href="mailto:moose@perl.org">moose@perl.org</a></li>
+ <li>Slides and exercises are in Moose's git repo:
+ <br />
+ <span style="font-size:80%; white-space: nowrap">git://git.moose.perl.org/moose-presentations/moose.git</span></li>
+ </ul>
+</div>
+
<div class="slide fake-slide0">
- <h1>The End (Really)</h1>
+ <h1>The End</h1>
</div>
</div>