From: Dave Rolsky Date: Wed, 2 Sep 2009 16:34:57 +0000 (-0500) Subject: Add some slides for Native delegation X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1c32806a415472ca126fcba161ec8e15ed45540f;p=gitmo%2Fmoose-presentations.git Add some slides for Native delegation --- diff --git a/moose-class/slides/index.html b/moose-class/slides/index.html index 5e678db..992d256 100644 --- a/moose-class/slides/index.html +++ b/moose-class/slides/index.html @@ -3303,6 +3303,58 @@ has history => (
+

Native Delegation

+ + +
+ +
+

Native Delegation - Array

+ +
package Person;
+use Moose;
+
+has _favorite_numbers => (
+    traits   => [ 'Array' ],
+    is       => 'ro',
+    isa      => 'ArrayRef[Int]',
+    default  => sub { [] },
+    init_arg => undef,
+    handles  =>
+      { favorite_numbers    => 'elements',
+        add_favorite_number => 'push',
+      },
+);
+ + +
+ +
+

Native Delegation - Counter

+ +
package Stack;
+use Moose;
+
+has depth => (
+    traits   => [ 'Counter' ],
+    is       => 'ro',
+    isa      => 'Int',
+    default  => 0,
+    init_arg => undef,
+    handles  =>
+      { _inc_depth => 'inc',
+        _dec_depth => 'dec',
+      },
+);
+
+ + +

Traits and Metaclasses