From: Arthur Axel 'fREW' Schmidt Date: Mon, 3 Sep 2012 15:31:32 +0000 (-0500) Subject: load class in addition to roles when using create_class_from_roles X-Git-Tag: v1.002000~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f52b98215874945b6f2f975a99c530c019bfbdbb;p=gitmo%2FRole-Tiny.git load class in addition to roles when using create_class_from_roles --- diff --git a/Changes b/Changes index c451a61..713988d 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,4 @@ + - load class in addition to roles when using create_class_from_roles - fix module name in Makefile.PL (RT#78591) 1.001005 - 2012-07-18 diff --git a/lib/Role/Tiny.pm b/lib/Role/Tiny.pm index 6620964..609f4a6 100644 --- a/lib/Role/Tiny.pm +++ b/lib/Role/Tiny.pm @@ -108,6 +108,7 @@ sub create_class_with_roles { die "No roles supplied!" unless @roles; + _load_module($superclass); { my %seen; $seen{$_}++ for @roles; diff --git a/t/lib/Bar.pm b/t/lib/Bar.pm new file mode 100644 index 0000000..9958b27 --- /dev/null +++ b/t/lib/Bar.pm @@ -0,0 +1,6 @@ +package Bar; + +sub new { bless {} => shift } +sub bar { 1 } + +1; diff --git a/t/lib/Baz.pm b/t/lib/Baz.pm new file mode 100644 index 0000000..bd52b93 --- /dev/null +++ b/t/lib/Baz.pm @@ -0,0 +1,7 @@ +package Baz; + +use Role::Tiny; + +sub baz { 1 } + +1; diff --git a/t/role-basic-bugs.t b/t/role-basic-bugs.t index f43a308..94443de 100644 --- a/t/role-basic-bugs.t +++ b/t/role-basic-bugs.t @@ -1,6 +1,6 @@ #!/usr/bin/env perl -use lib 'lib', 't/role-basic/lib'; +use lib 'lib', 't/role-basic/lib', 't/lib'; use MyTests; # multiple roles with the same role @@ -77,4 +77,6 @@ use MyTests; ::ok(Role::Tiny::does_role($object, "Role1"), 'Role1 consumed'); ::ok(Role::Tiny::does_role($object, 'Role2'), 'Role2 consumed'); } + +can_ok(Role::Tiny->create_class_with_roles(qw(Bar Baz))->new, qw(bar baz)); done_testing;