--- /dev/null
+package Moose::Deprecated;
+
+use strict;
+use warnings;
+
+our $VERSION = '1.08';
+$VERSION = eval $VERSION;
+our $AUTHORITY = 'cpan:STEVAN';
+
+use Package::DeprecationManager -deprecations => {
+ 'pre-0.94 MetaRole API' => '0.93',
+ 'Moose::Exporter with_caller' => '0.89',
+ },
+ -ignore => [qw( Moose Moose::Exporter Moose::Util::MetaRole )],
+ ;
+
+1;
use Class::MOP;
use List::MoreUtils qw( first_index uniq );
+use Moose::Deprecated;
use Moose::Util::MetaRole;
use Sub::Exporter 0.980;
use Sub::Name qw(subname);
my $exporting_package = $args{exporting_package} ||= caller();
+ if ( $args{with_caller} ) {
+ Moose::Deprecated::deprecated(
+ feature => 'Moose::Exporter with_caller',
+ message =>
+ 'The with_caller argument for Moose::Exporter has been deprecated'
+ );
+ }
+
$EXPORT_SPEC{$exporting_package} = \%args;
my @exports_from = $class->_follow_also($exporting_package);
return unless Class::MOP::class_of( $options{for_class} );
- Moose::Util::MetaRole::apply_metaroles(
- for => $options{for_class},
- %new_style_roles,
- %old_style_roles,
- );
+ if ( %new_style_roles || %old_style_roles ) {
+ Moose::Util::MetaRole::apply_metaroles(
+ for => $options{for_class},
+ %new_style_roles,
+ %old_style_roles,
+ );
+ }
Moose::Util::MetaRole::apply_base_class_roles(
for_class => $options{for_class},
use List::MoreUtils qw( all );
use List::Util qw( first );
+use Moose::Deprecated;
sub apply_metaclass_roles {
+ Moose::Deprecated::deprecated(
+ feature => 'pre-0.94 MetaRole API',
+ message =>
+ 'The old Moose::Util::MetaRole API (before version 0.94) has been deprecated'
+ );
+
goto &apply_metaroles;
}
sub _fixup_old_style_args {
my $args = shift;
- return if $args->{class_metaroles} || $args->{roles_metaroles};
+ return if $args->{class_metaroles} || $args->{role_metaroles};
+
+ Moose::Deprecated::deprecated(
+ feature => 'pre-0.94 MetaRole API',
+ message =>
+ 'The old Moose::Util::MetaRole API (before version 0.94) has been deprecated'
+ );
$args->{for} = delete $args->{for_class}
if exists $args->{for_class};
use Moose ();
sub wrapped2 {
- my $caller = shift;
+ my $caller = shift->name;
return $caller . ' called wrapped2';
}
}
Moose::Exporter->setup_import_methods(
- with_caller => ['wrapped2'],
- as_is => ['as_is1'],
- also => 'MooseX::Sugar',
+ with_meta => ['wrapped2'],
+ as_is => ['as_is1'],
+ also => 'MooseX::Sugar',
);
}
use Moose ();
sub has {
- my $caller = shift;
+ my $caller = shift->name;
return $caller . ' called has';
}
Moose::Exporter->setup_import_methods(
- with_caller => ['has'],
- also => 'Moose',
+ with_meta => ['has'],
+ also => 'Moose',
);
}
::stderr_like {
Moose::Exporter->setup_import_methods(
also => ['Moose'],
- with_caller => ['does_not_exist'],
+ with_meta => ['does_not_exist'],
);
} qr/^Trying to export undefined sub NonExistentExport::does_not_exist/,
"warns when a non-existent method is requested to be exported";
{
package AllOptions;
use Moose ();
+ use Moose::Deprecated -api_version => '0.88';
use Moose::Exporter;
Moose::Exporter->setup_import_methods(
my %p = @_;
Moose->init_meta(%p);
return Moose::Util::MetaRole::apply_metaroles(
- for_class => $p{for_class},
+ for => $p{for_class},
# Causes us to recurse through init_meta, as we have to
# load MyMetaclassRole from disk.
- metaclass_roles => [qw/MyMetaclassRole/],
+ class_metaroles => { class => [qw/MyMetaclassRole/] },
);
}
}
use Moose::Exporter;
Moose::Exporter->setup_import_methods(
- metaclass_roles => ['Foo::Trait::Class'],
- role_metaclass_roles => ['Foo::Trait::Class'],
- attribute_metaclass_roles => ['Foo::Trait::Attribute'],
- base_class_roles => ['Foo::Role::Base'],
+ class_metaroles => {
+ class => ['Foo::Trait::Class'],
+ attribute => ['Foo::Trait::Attribute'],
+ },
+ role_metaroles => { role => ['Foo::Trait::Class'] },
+ base_class_roles => ['Foo::Role::Base'],
);
}
use Moose ();
use Moose::Exporter;
- my ($import, $unimport, $init_meta) =
- Moose::Exporter->build_import_methods(
- also => 'Moose',
- metaclass_roles => ['Foo::Trait::Class'],
- attribute_metaclass_roles => ['Foo::Trait::Attribute'],
- base_class_roles => ['Foo::Role::Base'],
- install => [qw(import unimport)],
+ my ( $import, $unimport, $init_meta )
+ = Moose::Exporter->build_import_methods(
+ also => 'Moose',
+ class_metaroles => {
+ class => ['Foo::Trait::Class'],
+ attribute => ['Foo::Trait::Attribute'],
+ },
+ base_class_roles => ['Foo::Role::Base'],
+ install => [qw(import unimport)],
);
sub init_meta {
sub init_meta {
my ( $self, %options ) = @_;
return Moose::Util::MetaRole::apply_metaroles(
- for_class => Moose::Role->init_meta(%options),
+ for => Moose::Role->init_meta(%options),
role_metaroles => {
role => ['Role::WithCustomApplication'],
application_to_class =>
use Moose::Util::MetaRole;
+{
+ no warnings 'redefine';
+ *Moose::Deprecated::deprecated = sub { return };
+}
{
package My::Meta::Class;
use Test::More;
Moose::Exporter->setup_import_methods(
- with_caller => [ qw(with_prototype) ],
- as_is => [ qw(as_is_prototype) ],
+ with_meta => [qw(with_prototype)],
+ as_is => [qw(as_is_prototype)],
);
sub with_prototype (&) {
$code->();
}
-1;
\ No newline at end of file
+1;