Commit | Line | Data |
600f7f85 |
1 | =pod |
2 | |
3 | =head1 NAME |
4 | |
5 | Moose::Manual::Delta - Important Changes in Moose |
6 | |
7 | =head1 DESCRIPTION |
8 | |
0f13f53c |
9 | This documents any important or noteworthy changes in Moose, with a |
10 | focus on backwards. This does duplicate data from the F<Changes> file, |
11 | but aims to provide more details and when possible workarounds. |
12 | |
13 | Besides helping keep up with changes, you can also use this document |
14 | for finding the lowest version of Moose that supported a given |
15 | feature. If you encounter a problem and have a solution but don't see |
16 | it documented here, or think we missed an important feature, please |
17 | send us a patch. |
600f7f85 |
18 | |
f869fc4a |
19 | =head1 Version 0.75 |
20 | |
21 | L<Moose::Exporter> now accepts the C<-metaclass> option for easily |
22 | overriding the metaclass (without L<metaclass>). This works for classes |
23 | and roles. |
24 | |
39ab7714 |
25 | =head1 Version 0.74 |
26 | |
85cf0647 |
27 | Added a C<duck_type> sugar function to L<Moose::Util::TypeConstraints> |
28 | to make integration with non-Moose classes easier. It simply checks if |
29 | C<< $obj->can() >> a list of methods. |
39ab7714 |
30 | |
612fd754 |
31 | A number of methods (mostly inherited from L<Class::MOP>) have been |
32 | renamed with a leading underscore to indicate their internal-ness. The |
33 | old method names will still work for a while, but will warn that the |
34 | method has been renamed. In a few cases, the method will be removed |
35 | entirely in the future. This may affect MooseX authors who were using |
36 | these methods. |
37 | |
600f7f85 |
38 | =head1 Version 0.73 |
39 | |
0f13f53c |
40 | Calling C<subtype> with a name as the only argument now throws an |
600f7f85 |
41 | exception. If you want an anonymous subtype do: |
42 | |
43 | my $subtype = subtype as 'Foo'; |
44 | |
0f13f53c |
45 | This is related to the changes in version 0.71_01. |
600f7f85 |
46 | |
501db4e6 |
47 | The C<is_needed> method in L<Moose::Meta::Method::Destructor> is now |
48 | only usable as a class method. Previously, it worked as a class or |
49 | object method, with a different internal implementation for each |
50 | version. |
51 | |
52 | The internals of making a class immutable changed a lot in Class::MOP |
53 | 0.78_02, and Moose's internals have changed along with it. The |
54 | external C<< $metaclass->make_immutable >> method still works the same |
55 | way. |
56 | |
600f7f85 |
57 | =head1 Version 0.72 |
58 | |
0f13f53c |
59 | A mutable class accepted C<< Foo->new(undef) >> without complaint, |
60 | while an immutable class would blow up with an unhelpful error. Now, |
61 | in both cases we throw a helpful error instead. |
600f7f85 |
62 | |
0f13f53c |
63 | This "feature" was originally added to allow for cases such as this: |
600f7f85 |
64 | |
65 | my $args; |
0f13f53c |
66 | |
67 | if ( something() ) { |
68 | $args = {...}; |
600f7f85 |
69 | } |
0f13f53c |
70 | |
600f7f85 |
71 | return My::Class->new($args); |
72 | |
0f13f53c |
73 | But we decided this is a bad idea and a little too magical, because it |
74 | can easily mask real errors. |
600f7f85 |
75 | |
76 | =head1 Version 0.71_01 |
77 | |
0f13f53c |
78 | Calling C<type> or C<subtype> without the sugar helpers (C<as>, |
79 | C<where>, C<message>) is now deprecated. |
80 | |
81 | As a side effect, this meant we ended up using Perl prototypes on |
82 | C<as>, and code like this will no longer work: |
600f7f85 |
83 | |
84 | use Moose::Util::TypeConstraints; |
85 | use Declare::Constraints::Simple -All; |
0f13f53c |
86 | |
87 | subtype 'ArrayOfInts' |
600f7f85 |
88 | => as 'ArrayRef' |
89 | => IsArrayRef(IsInt); |
90 | |
91 | Instead it must be changed to this: |
92 | |
0f13f53c |
93 | subtype( |
94 | 'ArrayOfInts' => { |
95 | as => 'ArrayRef', |
96 | where => IsArrayRef(IsInt) |
97 | } |
600f7f85 |
98 | ); |
99 | |
0f13f53c |
100 | If you want to maintain backwards compat with older versions of Moose, |
101 | you must explicitly test Moose's C<VERSION>: |
600f7f85 |
102 | |
0f13f53c |
103 | if ( Moose->VERSION < 0.71_01 ) { |
104 | subtype 'ArrayOfInts' |
600f7f85 |
105 | => as 'ArrayRef' |
106 | => IsArrayRef(IsInt); |
107 | } |
108 | else { |
0f13f53c |
109 | subtype( |
110 | 'ArrayOfInts' => { |
111 | as => 'ArrayRef', |
112 | where => IsArrayRef(IsInt) |
113 | } |
600f7f85 |
114 | ); |
115 | } |
116 | |
117 | =head1 Version 0.70 |
118 | |
0f13f53c |
119 | We no longer pass the meta-attribute object as a final argument to |
120 | triggers. This actually changed for inlined code a while back, but the |
121 | non-inlined version and the docs were still out of date. |
122 | |
123 | If by some chance you actually used this feature, the workaround is |
124 | simple. You fetch the attribute object from out of the C<$self> |
125 | that is passed as the first argument to trigger, like so: |
126 | |
127 | has 'foo' => ( |
128 | is => 'ro', |
129 | isa => 'Any', |
130 | trigger => sub { |
131 | my ( $self, $value ) = @_; |
132 | my $attr = $self->meta->find_attribute_by_name('foo'); |
133 | |
134 | # ... |
135 | } |
136 | ); |
600f7f85 |
137 | |
138 | =head1 Version 0.66 |
139 | |
0f13f53c |
140 | If you created a subtype and passed a parent that Moose didn't know |
141 | about, it simply ignored the parent. Now it automatically creates the |
142 | parent as a class type. This may not be what you want, but is less |
143 | broken than before. |
600f7f85 |
144 | |
0f13f53c |
145 | You could declare a name with subtype such as "Foo!Bar". Moose would |
146 | accept this allowed, but if you used it in a parameterized type such |
147 | as "ArrayRef[Foo!Bar]" it wouldn't work. We now do some vetting on |
148 | names created via the sugar functions, so that they can only contain |
149 | alphanumerics, ":", and ".". |
600f7f85 |
150 | |
151 | =head1 Version 0.65 |
152 | |
153 | Methods created via an attribute can now fulfill a C<requires> |
0f13f53c |
154 | declaration for a role. Honestly we don't know why Stevan didn't make |
155 | this work originally, he was just insane or something. |
600f7f85 |
156 | |
0f13f53c |
157 | Stack traces from inlined code will now report the line and file as |
158 | being in your class, as opposed to in Moose guts. |
600f7f85 |
159 | |
160 | =head1 Version 0.62_02 |
161 | |
0f13f53c |
162 | When a class does not provide all of a role's required methods, the |
163 | error thrown now mentions all of the missing methods, as opposed to |
164 | just the first missing method. |
600f7f85 |
165 | |
0f13f53c |
166 | Moose will no longer inline a constructor for your class unless it |
5e26e3f2 |
167 | inherits its constructor from Moose::Object, and will warn when it |
168 | doesn't inline. If you want to force inlining anyway, pass |
169 | C<< "replace_constructor => 1 >> to C<make_immutable>. |
0f13f53c |
170 | |
171 | If you want to get rid of the warning, pass C<< inline_constructor => |
172 | 1 >>. |
600f7f85 |
173 | |
174 | =head1 Version 0.62 |
175 | |
0f13f53c |
176 | Removed the (deprecated) C<make_immutable> keyword. |
600f7f85 |
177 | |
178 | Removing an attribute from a class now also removes delegation |
0f13f53c |
179 | (C<handles>) methods installed for that attribute. This is correct |
600f7f85 |
180 | behavior, but if you were wrongly relying on it you might get bit. |
181 | |
182 | =head1 Version 0.58 |
183 | |
0f13f53c |
184 | Roles now add methods by calling C<add_method>, not |
185 | C<alias_method>. They make sure to always provide a method object, |
186 | which will be cloned internally. This means that it is now possible to |
187 | track the source of a method provided by a role, and even follow its |
188 | history through intermediate roles. This means that methods added by |
189 | a role now show up when looking at a class's method list/map. |
190 | |
191 | Parameter and Union args are now sorted, this makes Int|Str the same |
192 | constraint as Str|Int. Also, incoming type constraint strings are |
193 | normalized to remove all whitespace differences. This is mostly for |
194 | internals and should not affect outside code. |
195 | |
196 | L<Moose::Exporter> will no longer remove a subroutine that the |
197 | exporting package re-exports. Moose re-exports the Carp::confess |
198 | function, among others. The reasoning is that we cannot know whether |
199 | you have also explicitly imported those functions for your own use, so |
200 | we err on the safe side and always keep them. |
600f7f85 |
201 | |
202 | =head1 Version 0.56 |
203 | |
0f13f53c |
204 | C<Moose::init_meta> should now be called as a method. |
600f7f85 |
205 | |
0f13f53c |
206 | New modules for extension writers, L<Moose::Exporter> and |
207 | L<Moose::Util::MetaRole>. |
600f7f85 |
208 | |
209 | =head1 Version 0.55_01 |
210 | |
211 | Implemented metaclass traits (and wrote a recipe for it): |
212 | |
213 | use Moose -traits => 'Foo' |
214 | |
215 | This should make writing small Moose extensions a little |
216 | easier. |
217 | |
218 | =head1 Version 0.55 |
219 | |
220 | Fixed C<coerce> to accept anon types just like C<subtype> can. |
221 | So that you can do: |
222 | |
223 | coerce $some_anon_type => from 'Str' => via { ... }; |
224 | |
225 | =head1 Version 0.51 |
226 | |
52da380a |
227 | Added C<BUILDARGS>, a new step in C<< Moose::Object->new() >>. |
600f7f85 |
228 | |
229 | =head1 Version 0.49 |
230 | |
0f13f53c |
231 | Fixed how the C<< is => (ro|rw) >> works with custom defined |
232 | C<reader>, C<writer> and C<accessor> options. See the below table for |
600f7f85 |
233 | details: |
234 | |
235 | is => ro, writer => _foo # turns into (reader => foo, writer => _foo) |
236 | is => rw, writer => _foo # turns into (reader => foo, writer => _foo) |
237 | is => rw, accessor => _foo # turns into (accessor => _foo) |
238 | is => ro, accessor => _foo # error, accesor is rw |
239 | |
240 | =head1 Version 0.45 |
241 | |
0f13f53c |
242 | The C<before/around/after> method modifiers now support regexp |
243 | matching of method names. NOTE: this only works for classes, it is |
244 | currently not supported in roles, but, ... patches welcome. |
600f7f85 |
245 | |
0f13f53c |
246 | The C<has> keyword for roles now accepts the same array ref form that |
247 | L<Moose>.pm does for classes. |
600f7f85 |
248 | |
0f13f53c |
249 | A trigger on a read-only attribute is no longer an error, as it's |
250 | useful to trigger off of the constructor. |
600f7f85 |
251 | |
0f13f53c |
252 | Subtypes of parameterizable types now are parameterizable types |
253 | themselves. |
600f7f85 |
254 | |
255 | =head1 Version 0.44 |
256 | |
0f13f53c |
257 | Fixed issue where C<DEMOLISHALL> was eating the value in C<$@>, and so |
258 | not working correctly. It still kind of eats them, but so does vanilla |
259 | perl. |
600f7f85 |
260 | |
261 | =head1 Version 0.41 |
262 | |
0f13f53c |
263 | Inherited attributes may now be extended without restriction on the |
600f7f85 |
264 | type ('isa', 'does'). |
265 | |
0f13f53c |
266 | The entire set of Moose::Meta::TypeConstraint::* classes were |
267 | refactored in this release. If you were relying on their internals you |
268 | should test your code carefully. |
600f7f85 |
269 | |
270 | =head1 Version 0.40 |
271 | |
0f13f53c |
272 | Documenting the use of '+name' with attributes that come from recently |
273 | composed roles. It makes sense, people are using it, and so why not |
274 | just officially support it. |
600f7f85 |
275 | |
0f13f53c |
276 | The C<< Moose::Meta::Class->create >> method now supports roles. |
600f7f85 |
277 | |
86b96832 |
278 | It is now possible to make anonymous enum types by passing C<enum> an |
279 | array reference instead of the C<< enum $name => @values >>. |
600f7f85 |
280 | |
281 | =head1 Version 0.37 |
282 | |
0f13f53c |
283 | Added the C<make_immutable> keyword as a shortcut to calling |
284 | C<make_immutable> on the meta object. This eventually got removed! |
600f7f85 |
285 | |
0f13f53c |
286 | Made C<< init_arg => undef >> work in Moose. This means "do not accept |
600f7f85 |
287 | a constructor parameter for this attribute". |
288 | |
0f13f53c |
289 | Type errors now use the provided message. Prior to this release they |
290 | didn't. |
600f7f85 |
291 | |
292 | =head1 Version 0.34 |
293 | |
294 | Moose is now a postmodern object system :) |
295 | |
0f13f53c |
296 | The Role system was completely refactored. It is 100% backwards |
297 | compat, but the internals were totally changed. If you relied on the |
298 | internals then you are advised to test carefully. |
600f7f85 |
299 | |
300 | Added method exclusion and aliasing for Roles in this release. |
301 | |
0f13f53c |
302 | Added the L<Moose::Util::TypeConstraints::OptimizedConstraints> |
303 | module. |
600f7f85 |
304 | |
0f13f53c |
305 | Passing a list of values to an accessor (which is only expecting one |
306 | value) used to be silently ignored, now it throws an error. |
600f7f85 |
307 | |
308 | =head1 Version 0.26 |
309 | |
0f13f53c |
310 | Added parameterized types and did a pretty heavy refactoring of the |
311 | type constraint system. |
600f7f85 |
312 | |
0f13f53c |
313 | Better framework extendability and better support for "making your own |
314 | Moose". |
600f7f85 |
315 | |
316 | =head1 Version 0.25 or before |
317 | |
0f13f53c |
318 | Honestly, you shouldn't be using versions of Moose that are this old, |
319 | so many bug fixes and speed improvements have been made you would be |
320 | crazy to not upgrade. |
600f7f85 |
321 | |
0f13f53c |
322 | Also, I am tired of going through the Changelog so I am stopping here, |
323 | if anyone would like to continue this please feel free. |
600f7f85 |
324 | |
325 | =head1 AUTHOR |
326 | |
327 | Stevan Little E<lt>stevan@iinteractive.comE<gt> |
328 | |
329 | =head1 COPYRIGHT AND LICENSE |
330 | |
331 | Copyright 2009 by Infinity Interactive, Inc. |
332 | |
333 | L<http://www.iinteractive.com> |
334 | |
335 | This library is free software; you can redistribute it and/or modify |
336 | it under the same terms as Perl itself. |
337 | |
0f13f53c |
338 | =cut |