From: Dave Rolsky Date: Thu, 24 Sep 2009 20:31:46 +0000 (-0500) Subject: Add an introduce yourself slide. Expand Native delegation slides. Add a few slides... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ba3e6f3b43767d159a22c4884f0a7e3720bda4c2;p=gitmo%2Fmoose-presentations.git Add an introduce yourself slide. Expand Native delegation slides. Add a few slides on curried delegations --- diff --git a/moose-class/slides/index.html b/moose-class/slides/index.html index 629a3ca..98e190a 100644 --- a/moose-class/slides/index.html +++ b/moose-class/slides/index.html @@ -56,6 +56,16 @@ img#me05 {top: 43px;left: 36px;}
+

Introduce Yourselves

+ + +
+ +

Moose Summed Up

-

Native Delegation - Array

+

Native Delegation - Array(Ref)

+ + +
+ +
+

Native Delegation - Array(Ref)

package Person;
 use Moose;
@@ -3340,24 +3370,64 @@ has _favorite_numbers => (
 
-

Native Delegation - Counter

+

Native Delegation - Array(Ref)

+ +
my $person = Person->new();
+
+$person->add_favorite_number(7);
+$person->add_favorite_number(42);
+
+print "$_\n"
+    for $person->favorite_numbers;
+
+# 7
+# 42
+
+ +
+

Native Delegation

-
package Stack;
+  
    +
  • Native types are ... +
      +
    • Number - add, mul, ...
    • +
    • String - append, chop, ...
    • +
    • Counter - inc, dec, ...
    • +
    • Bool - set, toggle, ...
    • +
    • Hash - get, set, ...
    • +
    • Array - already saw it
    • +
    • Code - execute, that's it
    • +
    +
  • +
+
+ +
+

Curried Delegation

+ +
    +
  • A delegation with some preset arguments
  • +
  • Works with object or Native delegation
  • +
+
+ +
+

Curried Delegation

+ +
package Person;
 use Moose;
-has depth => (
-    traits   => [ 'Counter' ],
-    is       => 'ro',
-    isa      => 'Int',
-    default  => 0,
-    init_arg => undef,
-    handles  =>
-      { _inc_depth => 'inc',
-        _dec_depth => 'dec',
-      },
+has account => (
+    is      => 'ro',
+    isa     => 'BankAccount',
+    handles => {
+        receive_100 =>
+            [ 'deposit', 100 ]
+        give_100    =>
+            [ 'withdraw', 100 ]
+    },
 );
-

Traits and Metaclasses