X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=moose-class%2Fslides%2Findex.html;h=e3814b78837583319bfb14b980b4d1a9edde0993;hb=3258951f22a6aed1774ec682fe4ad1365e154405;hp=056e11502c3d8be6dc75c993af7233d04db53201;hpb=e284f2b4abe2bfdb65884c34b2724401db14371f;p=gitmo%2Fmoose-presentations.git
diff --git a/moose-class/slides/index.html b/moose-class/slides/index.html
index 056e115..e3814b7 100644
--- a/moose-class/slides/index.html
+++ b/moose-class/slides/index.html
@@ -2962,10 +2962,21 @@ has transaction_history => (
+
Specio
+
+
+ - My attempt to replace
MooseX::Types
and built-in types
+ - Third-system effect?
+ - Still alpha - needs some work
+
+
+
+
Recommendation
- - Use
MooseX::Types
+ - Use
MooseX::Types
for now
+ - Switch to
Specio
when it's ready?
- Compile time error catching and automatic namespacing are huge wins
- Docs from
Moose::Util::TypeConstraints
are 98% compatible with MooseX::Types
anyway
- A function exported by a type library works wherever a type name would
@@ -3190,8 +3201,12 @@ has account => (
},
- $person->receive_money
= $person->account->deposit
- $person->give_money
= $person->account->withdraw
+ $person->receive_money
+
+ = $person->account->deposit
+ $person->give_money
+
+ = $person->account->withdraw
@@ -3358,82 +3373,6 @@ $person->account->deposit(100);
-
Traits and Metaclasses
-
-
- - The ultimate in customization
- - Per attribute metaclasses
- - Per attribute roles applied to the attribute metaclass
- - Change the meta-level behavior
-
-
-
-
-
Traits and Metaclasses
-
-
- - The default metaclass is
Moose::Meta::Attribute
- - Controls accessor generation, defaults, delegation, etc.
- - Adding a role to this metaclass (or replacing it) allows for infinite customization
-
-
-
-
-
Traits and Metaclasses
-
-
- - Can add/alter/remove an attribute parameter (from
has
)
- - Can change behavior of created attribute
-
-
-
-
-
Simple Trait Example
-
-
package Person;
-use Moose;
-use MooseX::LabeledAttributes;
-
-has ssn => (
- traits => [ 'Labeled' ],
- is => 'ro',
- isa => 'Str',
- label => 'Social Security Number',
-);
-print Person->meta
- ->get_attribute('ssn')->label;
-
-
-
-
Simple Metaclass Example
-
-
package Person;
-use Moose;
-use MooseX::LabeledAttributes;
-
-has ssn => (
- metaclass =>
- 'MooseX::Meta::Attribute::Labeled',
- is => 'ro',
- isa => 'Str',
- label => 'Social Security Number',
-);
-print Person->meta
- ->get_attribute('ssn')->label;
-
-
-
-
Traits vs Metaclass
-
-
- - Can apply any mix of traits to an attribute
- - But just one metaclass
- - Traits (aka roles) can cooperate
- - Metaclasses require you to pick just one
-
-
-
-
Advanced Attributes Summary
@@ -3441,7 +3380,6 @@ print Person->meta
- Use trigger to do an action post-attribute write
- Use delegations to hide "internal" objects
- Use native delegations to treat Perl types as objects
- - Traits and metaclasses let you extend Moose's core attribute features
@@ -3674,12 +3612,13 @@ with HasCollection => { type => 'Int' };
@@ -3688,7 +3627,7 @@ with HasCollection => { type => 'Int' };