From: Andreas Marienborg Date: Wed, 18 Nov 2009 08:22:20 +0000 (+0100) Subject: Add [DEPRECATED] and MigrationGuide X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fmigration-guide;p=gitmo%2FMooseX-AttributeHelpers.git Add [DEPRECATED] and MigrationGuide The migration guide is quite simple atm --- diff --git a/lib/MooseX/AttributeHelpers.pm b/lib/MooseX/AttributeHelpers.pm index 6e365ec..f57f0aa 100644 --- a/lib/MooseX/AttributeHelpers.pm +++ b/lib/MooseX/AttributeHelpers.pm @@ -38,7 +38,15 @@ __END__ =head1 NAME -MooseX::AttributeHelpers - Extend your attribute interfaces +MooseX::AttributeHelpers - [DEPRECATED] Extend your attribute interfaces + +=head1 MIGRATION GUIDE + +This module started it's life as an experiment that has lately been migrated +to core in a slightly different form: L + +We have written a short L to help you +migrate your code =head1 SYNOPSIS diff --git a/lib/MooseX/AttributeHelpers/MigrationGuide.pod b/lib/MooseX/AttributeHelpers/MigrationGuide.pod new file mode 100644 index 0000000..9b825a6 --- /dev/null +++ b/lib/MooseX/AttributeHelpers/MigrationGuide.pod @@ -0,0 +1,62 @@ +=head1 MIGRATION GUIDE + +So you want to migrate your wonderful MooseX::AttributeHelpers code to the +new and shiny L? Then you've come to the +right place at least :) + +=head2 DIFFERENCES + +There are some subtle differences between the two, and we will try to hilight +them with small code snipptes + +First a MX::AH example: + + use Moose; + use MooseX::AttributeHelpers; + + has 'items' => ( + metaclass => 'Collection::List', + is => 'ro', + isa => 'ArrayRef', + provides => { + 'grep' => 'filter_items', + } + ); + +And now the updated way using the Native traits from Moose it self + + use Moose; + + has 'items' => ( + traits => ['Array'], + is => 'ro', + isa => 'ArrayRef', + handles => { + 'filter_items' => 'grep', + }, + ); + +There are basicly three diffrences in the simple cases. + +=over + +=item metaclass becomes trait + +In the native way of doing things, we add a trait to our attribute, where +we in AttributeHelpers assigned a metaclass. + +=item provides is removed in favour of the standard handles + +Where we used to have a special syntax for method provides in the old way +of doing things, we now use the standard handles in the native way. There is +one noteable exception to the usual handles in has (), which is that for +the Native traits, we only accept a hashref. + +This leads us over to the last difference of the day + +=item the order of handles is the reversed order of provides + +You might have spotted this already, you clever you? This is done +to conform to the standard way handles works, and should make it easier +and clearer in the long run. +