Tweaked docs in CMOP::Deprecated.
failed to update the method map properly. RT #48985. Reported by Paul
Mooney. (Dave Rolsky)
- The get_method_map method is now private. The public version is
- available as a deprecated method, but the values of the hash reference
- may now be either Class::MOP::Method objects _or_ raw sub
- references. (Dave Rolsky)
+ available as a deprecated method. (Dave Rolsky)
0.92_01 Thu, Sep 10, 2009
* Class::MOP::Package
use strict;
use warnings;
-use Carp qw(cluck);
+
+use Carp qw( cluck );
+use Scalar::Util qw( blessed );
our $VERSION = '0.92_01';
$VERSION = eval $VERSION;
package
Class::MOP::Package;
+sub get_method_map {
+ Class::MOP::Deprecated::warn(
+ 'The get_method_map method has been made private.'
+ . " The public version is deprecated and will be removed in a future release.\n"
+ );
+ my $self = shift;
+
+ my $map = $self->_full_method_map;
+
+ $map->{$_} = $self->get_method($_)
+ for grep { !blessed( $map->{$_} ) } keys %{$map};
+
+ return $map;
+}
+
package
Class::MOP::Module;
=head1 FUNCTIONS
-This class provides methods that have been deprecated but remain for backward compatibility.
-
-If you specify C<< -compatible => $version >>, you can use deprecated features without warnings.
-Note that this special treatment is package-scoped.
-
-=over 4
-
-=item B<Class::MOP::Deprecated::warn($message)>
-
-Checks compatibility for the caller feature, and produces warnings if needed.
-
-This function is used in internals.
+This class provides methods that have been deprecated but remain for backward
+compatibility.
-=back
+If you specify C<< -compatible => $version >>, you can use deprecated features
+without warnings. Note that this special treatment is limited to the package
+that loads C<Class::MOP::Deprecated>.
=head1 AUTHORS
use strict;
use warnings;
-use Test::More tests => 302;
+use Test::More tests => 304;
use Test::Exception;
use Class::MOP;
get_method_list _full_method_map
_deconstruct_variable_name
+
+ get_method_map
);
my @class_mop_module_methods = qw(
use strict;
use warnings;
-use Test::More tests => 4;
+use Test::More tests => 6;
use Test::Exception;
use Carp;
} 'safe in an inner class';
}
+{
+ package Quux;
+
+ use Class::MOP::Deprecated -compatible => 0.92;
+ use Scalar::Util qw( blessed );
+
+ use metaclass;
+
+ sub foo {42}
+
+ Quux->meta->add_method( bar => sub {84} );
+
+ my $map = Quux->meta->get_method_map;
+ my @method_objects = grep { blessed($_) } values %{$map};
+
+ ::is( scalar @method_objects, 3,
+ 'get_method_map still returns all values as method object' );
+ ::is_deeply( [ sort keys %{$map} ],
+ [ qw( bar foo meta ) ],
+ 'get_method_map returns expected methods' );
+}
],
'Class::MOP::Class::Immutable::Trait' => ['.+'],
'Class::MOP::Class::Immutable::Class::MOP::Class' => ['.+'],
- 'Class::MOP::Instance' => [
+ 'Class::MOP::Deprecated' => ['.+'],
+
+ 'Class::MOP::Instance' => [
qw( BUILDARGS
bless_instance_structure
is_dependent_on_superclasses ),
initialize_body
)
],
- 'Class::MOP::Module' => ['create'],
- 'Class::MOP::Package' => ['wrap_method_body'],
+ 'Class::MOP::Module' => ['create'],
+ 'Class::MOP::Package' => [ 'get_method_map', 'wrap_method_body' ],
);
for my $module ( sort @modules ) {