- Some tests that used Test::Warn if it was available failed
with older versions of Test::Warn. Reported by Fayland. (Dave
Rolsky)
+ * Moose::Meta::Class
+ - In create(), do not pass "roles" option to the superclass
+ - added related test that creates an anon metaclass with
+ a required attribute
-0.58
+0.58 Sat September 20, 2008
!! This release has an incompatible change regarding !!
!! how roles add methods to a class !!
t/050_metaclasses/016_metarole_w_metaclass_pm.t
t/050_metaclasses/017_use_base_of_moose.t
t/050_metaclasses/018_throw_error.t
+t/050_metaclasses/019_create_anon_with_required_attr.t
t/060_compat/001_module_refresh_compat.t
t/060_compat/002_moose_respects_base.t
t/060_compat/003_foreign_inheritence.t
(ref $options{roles} eq 'ARRAY')
|| $self->throw_error("You must pass an ARRAY ref of roles", data => $options{roles})
if exists $options{roles};
+ my $roles = delete $options{roles};
my $class = $self->SUPER::create($package_name, %options);
- if (exists $options{roles}) {
- Moose::Util::apply_all_roles($class, @{$options{roles}});
+ if ($roles) {
+ Moose::Util::apply_all_roles( $class, @$roles );
}
return $class;
--- /dev/null
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 3;
+use Test::Exception;
+
+{
+ package HasFoo;
+ use Moose::Role;
+ has 'foo' => (
+ is => 'ro',
+ isa => 'Str',
+ required => 1,
+ );
+
+}
+
+{
+ package My::Metaclass;
+ use Moose;
+ extends 'Moose::Meta::Class';
+ with 'HasFoo';
+}
+
+package main;
+
+my $anon;
+lives_ok {
+ $anon = My::Metaclass->create_anon_class( foo => 'this' );
+} 'create anon class';
+isa_ok( $anon, 'My::Metaclass' );
+cmp_ok( $anon->foo, 'eq', 'this', 'foo is this' );
+