Add [DEPRECATED] and MigrationGuide
[gitmo/MooseX-AttributeHelpers.git] / lib / MooseX / AttributeHelpers / MigrationGuide.pod
CommitLineData
6af1e11b 1=head1 MIGRATION GUIDE
2
3So you want to migrate your wonderful MooseX::AttributeHelpers code to the
4new and shiny L<Moose::Meta::Attribute::Native>? Then you've come to the
5right place at least :)
6
7=head2 DIFFERENCES
8
9There are some subtle differences between the two, and we will try to hilight
10them with small code snipptes
11
12First a MX::AH example:
13
14 use Moose;
15 use MooseX::AttributeHelpers;
16
17 has 'items' => (
18 metaclass => 'Collection::List',
19 is => 'ro',
20 isa => 'ArrayRef',
21 provides => {
22 'grep' => 'filter_items',
23 }
24 );
25
26And now the updated way using the Native traits from Moose it self
27
28 use Moose;
29
30 has 'items' => (
31 traits => ['Array'],
32 is => 'ro',
33 isa => 'ArrayRef',
34 handles => {
35 'filter_items' => 'grep',
36 },
37 );
38
39There are basicly three diffrences in the simple cases.
40
41=over
42
43=item metaclass becomes trait
44
45In the native way of doing things, we add a trait to our attribute, where
46we in AttributeHelpers assigned a metaclass.
47
48=item provides is removed in favour of the standard handles
49
50Where we used to have a special syntax for method provides in the old way
51of doing things, we now use the standard handles in the native way. There is
52one noteable exception to the usual handles in has (), which is that for
53the Native traits, we only accept a hashref.
54
55This leads us over to the last difference of the day
56
57=item the order of handles is the reversed order of provides
58
59You might have spotted this already, you clever you? This is done
60to conform to the standard way handles works, and should make it easier
61and clearer in the long run.
62