* Moose::Exporter
- Make "use Moose -metaclass => 'Foo'" do alias resolution, like -traits
does. (doy)
+ - Allow specifying role options (alias, excludes, MXRP stuff) in the
+ arrayref passed to "use Moose -traits" (doy)
* Moose::Util
- Add functions meta_class_alias and meta_attribute_alias for creating
. ref $meta );
my @resolved_traits
- = map { Moose::Util::resolve_metatrait_alias( $type => $_ ) }
+ = map {
+ ref $_ ? $_ : Moose::Util::resolve_metatrait_alias( $type => $_ )
+ }
@$traits;
return unless @resolved_traits;
This overrides the parent's method in order to accept a C<roles>
option. This should be an array reference containing one more roles
-that the class does.
+that the class does, each optionally followed by a hashref of options.
my $metaclass = Moose::Meta::Class->create( 'New::Class', roles => [...] );
my $meta = Class::MOP::Class->initialize($existing_class);
return $existing_class
- if $meta->can('does_role') && all { $meta->does_role($_) } @{$roles};
+ if $meta->can('does_role') && all { $meta->does_role($_) }
+ grep { !ref $_ } @{$roles};
return Moose::Meta::Class->create_anon_class(
superclasses => $superclasses,
#!/usr/bin/env perl
use strict;
use warnings;
-use Test::More tests => 4;
+use Test::More tests => 5;
{
package My::Attribute::Trait;
alias => {
reversed_name => 'reversed',
},
+ excludes => 'reversed_name',
},
],
is => 'bare',
my $other_attr = My::Other::Class->meta->get_attribute('foo');
is($other_attr->reversed, 'oof', 'the aliased method is in the attribute');
ok(!$other_attr->can('enam'), "the method was not installed under the other class' alias");
+ok(!$other_attr->can('reversed_name'), "the method was not installed under the original name when that was excluded");
#!/usr/bin/env perl
use strict;
use warnings;
-use Test::More skip_all => "Feature not implemented yet";
-#use Test::More tests => 1;
+use Test::More tests => 5;
{
package My::Trait;
];
}
-is(My::Class->meta->enam, 'ssalC::yM', 'parameterized trait applied');
+{
+ package My::Other::Class;
+ use Moose -traits => [
+ 'My::Trait' => {
+ alias => {
+ reversed_name => 'reversed',
+ },
+ excludes => 'reversed_name',
+ },
+ ];
+}
+
+my $meta = My::Class->meta;
+is($meta->enam, 'ssalC::yM', 'parameterized trait applied');
+ok(!$meta->can('reversed'), "the method was not installed under the other class' alias");
+
+my $other_meta = My::Other::Class->meta;
+is($other_meta->reversed, 'ssalC::rehtO::yM', 'parameterized trait applied');
+ok(!$other_meta->can('enam'), "the method was not installed under the other class' alias");
+ok(!$other_meta->can('reversed_name'), "the method was not installed under the original name when that was excluded");