1 package Class::MOP::Deprecated;
7 use Scalar::Util qw( blessed );
10 $VERSION = eval $VERSION;
11 our $AUTHORITY = 'cpan:STEVAN';
15 # features deprecated before 0.93
16 'Class::MOP::HAVE_ISAREV' => 0.93,
17 'Class::MOP::subname' => 0.93,
18 'Class::MOP::in_global_destruction' => 0.93,
20 'Class::MOP::Package::get_method_map' => 0.93,
22 'Class::MOP::Class::construct_class_instance' => 0.93,
23 'Class::MOP::Class::check_metaclass_compatibility' => 0.93,
24 'Class::MOP::Class::create_meta_instance' => 0.93,
25 'Class::MOP::Class::clone_instance' => 0.93,
26 'Class::MOP::Class::alias_method' => 0.93,
27 'Class::MOP::Class::compute_all_applicable_methods' => 0.93,
28 'Class::MOP::Class::compute_all_applicable_attributes' => 0.93,
29 'Class::MOP::Class::get_attribute_map' => 0.95,
31 'Class::MOP::Instance::bless_instance_structure' => 0.93,
33 'Class::MOP::Attribute::process_accessors' => 0.93,
35 'Class::MOP::Method::Accessor::initialize_body' => 0.93,
36 'Class::MOP::Method::Accessor::generate_accessor_method' => 0.93,
37 'Class::MOP::Method::Accessor::generate_reader_method' => 0.93,
38 'Class::MOP::Method::Accessor::generate_writer_method' => 0.93,
39 'Class::MOP::Method::Accessor::generate_predicate_method' => 0.93,
40 'Class::MOP::Method::Accessor::generate_clearer_method' => 0.93,
41 'Class::MOP::Method::Accessor::generate_accessor_method_inline' => 0.93,
42 'Class::MOP::Method::Accessor::generate_reader_method_inline' => 0.93,
43 'Class::MOP::Method::Accessor::generate_writer_method_inline' => 0.93,
44 'Class::MOP::Method::Accessor::generate_clearer_method_inline' => 0.93,
45 'Class::MOP::Method::Accessor::generate_predicate_method_inline' => 0.93,
47 'Class::MOP::Method::Constructor::meta_instance' => 0.93,
48 'Class::MOP::Method::Constructor::attributes' => 0.93,
49 'Class::MOP::Method::Constructor::initialize_body' => 0.93,
50 'Class::MOP::Method::Constructor::generate_constructor_method' => 0.93,
51 'Class::MOP::Method::Constructor::generate_constructor_method_inline' =>
58 my ( $class, %args ) = @_;
60 if ( defined( my $compat_version = delete $args{-compatible} ) ) {
61 $Registry{ (caller) } = $compat_version;
65 my $unknowns = join q{ }, keys %args;
66 cluck "Unknown argument(s) for $class->import: $unknowns.\n";
72 my ( $package, undef, undef, $feature ) = caller(1);
75 while ( $package && !defined( $compat_version = $Registry{$package} ) ) {
76 $package =~ s/ :: \w+ \z//xms or last;
79 my $deprecated_at = $DeprecatedAt{$feature}
80 or die "Unregistered deprecated feature: $feature";
82 if ( !defined($compat_version)
83 || $compat_version >= $DeprecatedAt{$feature} ) {
92 Class::MOP::Deprecated::warn(
93 "Class::MOP::HAVE_ISAREV is deprecated and will be removed in a future release. It has always returned 1 anyway."
99 Class::MOP::Deprecated::warn(
100 "Class::MOP::subname is deprecated. Please use Sub::Name directly.");
102 goto \&Sub::Name::subname;
105 sub in_global_destruction {
106 Class::MOP::Deprecated::warn(
107 "Class::MOP::in_global_destruction is deprecated. Please use Devel::GlobalDestruction directly."
109 require Devel::GlobalDestruction;
110 goto \&Devel::GlobalDestruction::in_global_destruction;
117 Class::MOP::Deprecated::warn(
118 'The get_method_map method has been made private.'
119 . " The public version is deprecated and will be removed in a future release.\n"
123 my $map = $self->_full_method_map;
125 $map->{$_} = $self->get_method($_)
126 for grep { !blessed( $map->{$_} ) } keys %{$map};
137 sub construct_class_instance {
138 Class::MOP::Deprecated::warn(
139 'The construct_class_instance method has been made private.'
140 . " The public version is deprecated and will be removed in a future release.\n"
142 shift->_construct_class_instance(@_);
145 sub check_metaclass_compatibility {
146 Class::MOP::Deprecated::warn(
147 'The check_metaclass_compatibility method has been made private.'
148 . " The public version is deprecated and will be removed in a future release.\n"
150 shift->_check_metaclass_compatibility(@_);
153 sub construct_instance {
154 Class::MOP::Deprecated::warn(
155 'The construct_instance method has been made private.'
156 . " The public version is deprecated and will be removed in a future release.\n"
158 shift->_construct_instance(@_);
161 sub create_meta_instance {
162 Class::MOP::Deprecated::warn(
163 'The create_meta_instance method has been made private.'
164 . " The public version is deprecated and will be removed in a future release.\n"
166 shift->_create_meta_instance(@_);
170 Class::MOP::Deprecated::warn(
171 'The clone_instance method has been made private.'
172 . " The public version is deprecated and will be removed in a future release.\n"
174 shift->_clone_instance(@_);
178 Class::MOP::Deprecated::warn(
179 "The alias_method method is deprecated. Use add_method instead.\n");
181 shift->add_method(@_);
184 sub compute_all_applicable_methods {
185 Class::MOP::Deprecated::warn(
186 'The compute_all_applicable_methods method is deprecated.'
187 . " Use get_all_methods instead.\n" );
192 class => $_->package_name,
193 code => $_, # sigh, overloading
195 } shift->get_all_methods(@_);
198 sub compute_all_applicable_attributes {
199 Class::MOP::Deprecated::warn(
200 'The compute_all_applicable_attributes method has been deprecated.'
201 . " Use get_all_attributes instead.\n" );
203 shift->get_all_attributes(@_);
206 sub get_attribute_map {
207 Class::MOP::Deprecated::warn(
208 "The get_attribute_map method has been deprecated.\n");
210 shift->_attribute_map(@_);
214 Class::MOP::Instance;
216 sub bless_instance_structure {
217 Class::MOP::Deprecated::warn(
218 'The bless_instance_structure method is deprecated.'
219 . " It will be removed in a future release.\n" );
221 my ( $self, $instance_structure ) = @_;
222 bless $instance_structure, $self->_class_name;
226 Class::MOP::Attribute;
228 sub process_accessors {
229 Class::MOP::Deprecated::warn(
230 'The process_accessors method has been made private.'
231 . " The public version is deprecated and will be removed in a future release.\n"
233 shift->_process_accessors(@_);
237 Class::MOP::Method::Accessor;
239 sub initialize_body {
240 Class::MOP::Deprecated::warn(
241 'The initialize_body method has been made private.'
242 . " The public version is deprecated and will be removed in a future release.\n"
244 shift->_initialize_body;
247 sub generate_accessor_method {
248 Class::MOP::Deprecated::warn(
249 'The generate_accessor_method method has been made private.'
250 . " The public version is deprecated and will be removed in a future release.\n"
252 shift->_generate_accessor_method;
255 sub generate_reader_method {
256 Class::MOP::Deprecated::warn(
257 'The generate_reader_method method has been made private.'
258 . " The public version is deprecated and will be removed in a future release.\n"
260 shift->_generate_reader_method;
263 sub generate_writer_method {
264 Class::MOP::Deprecated::warn(
265 'The generate_writer_method method has been made private.'
266 . " The public version is deprecated and will be removed in a future release.\n"
268 shift->_generate_writer_method;
271 sub generate_predicate_method {
272 Class::MOP::Deprecated::warn(
273 'The generate_predicate_method method has been made private.'
274 . " The public version is deprecated and will be removed in a future release.\n"
276 shift->_generate_predicate_method;
279 sub generate_clearer_method {
280 Class::MOP::Deprecated::warn(
281 'The generate_clearer_method method has been made private.'
282 . " The public version is deprecated and will be removed in a future release.\n"
284 shift->_generate_clearer_method;
287 sub generate_accessor_method_inline {
288 Class::MOP::Deprecated::warn(
289 'The generate_accessor_method_inline method has been made private.'
290 . " The public version is deprecated and will be removed in a future release.\n"
292 shift->_generate_accessor_method_inline;
295 sub generate_reader_method_inline {
296 Class::MOP::Deprecated::warn(
297 'The generate_reader_method_inline method has been made private.'
298 . " The public version is deprecated and will be removed in a future release.\n"
300 shift->_generate_reader_method_inline;
303 sub generate_writer_method_inline {
304 Class::MOP::Deprecated::warn(
305 'The generate_writer_method_inline method has been made private.'
306 . " The public version is deprecated and will be removed in a future release.\n"
308 shift->_generate_writer_method_inline;
311 sub generate_predicate_method_inline {
312 Class::MOP::Deprecated::warn(
313 'The generate_predicate_method_inline method has been made private.'
314 . " The public version is deprecated and will be removed in a future release.\n"
316 shift->_generate_predicate_method_inline;
319 sub generate_clearer_method_inline {
320 Class::MOP::Deprecated::warn(
321 'The generate_clearer_method_inline method has been made private.'
322 . " The public version is deprecated and will be removed in a future release.\n"
324 shift->_generate_clearer_method_inline;
328 Class::MOP::Method::Constructor;
331 Class::MOP::Deprecated::warn(
332 'The meta_instance method has been made private.'
333 . " The public version is deprecated and will be removed in a future release.\n"
335 shift->_meta_instance;
339 Class::MOP::Deprecated::warn(
340 'The attributes method has been made private.'
341 . " The public version is deprecated and will be removed in a future release.\n"
344 return shift->_attributes;
347 sub initialize_body {
348 Class::MOP::Deprecated::warn(
349 'The initialize_body method has been made private.'
350 . " The public version is deprecated and will be removed in a future release.\n"
352 shift->_initialize_body;
355 sub generate_constructor_method {
356 Class::MOP::Deprecated::warn(
357 'The generate_constructor_method method has been made private.'
358 . " The public version is deprecated and will be removed in a future release.\n"
360 shift->_generate_constructor_method;
363 sub generate_constructor_method_inline {
364 Class::MOP::Deprecated::warn(
365 'The generate_constructor_method_inline method has been made private.'
366 . " The public version is deprecated and will be removed in a future release.\n"
368 shift->_generate_constructor_method_inline;
379 Class::MOP::Deprecated - List of deprecated methods
383 use Class::MOP::Deprecated -compatible => $version;
387 This class provides methods that have been deprecated but remain for backward
390 If you specify C<< -compatible => $version >>, you can use deprecated features
391 without warnings. Note that this special treatment is limited to the package
392 that loads C<Class::MOP::Deprecated>.
396 Goro Fuji E<lt>gfuji@cpan.orgE<gt>
398 =head1 COPYRIGHT AND LICENSE
400 Copyright 2006-2010 by Infinity Interactive, Inc.
402 L<http://www.iinteractive.com>
404 This library is free software; you can redistribute it and/or modify
405 it under the same terms as Perl itself.