X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=moose-class%2Fslides%2Findex.html;h=98e190a312cc6d8648c6f7a310e8299b57c392fb;hb=ba3e6f3b43767d159a22c4884f0a7e3720bda4c2;hp=629a3ca2e8d8f04d1bb5e4c6b54874b6eaadeb91;hpb=4bb8a45d8b2379d4c9081e2552b9c29d24ed9514;p=gitmo%2Fmoose-presentations.git 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