my $class = shift;
strictures->import;
*{_getglob("${target}::extends")} = sub {
+ _load_module($_) for @_;
*{_getglob("${target}::ISA")} = \@_;
};
*{_getglob("${target}::with")} = sub {
use strictures 1;
use base qw(Exporter);
-our @EXPORT = qw(_getglob _install_modifier _maybe_load_module);
+our @EXPORT = qw(_getglob _install_modifier _load_module _maybe_load_module);
sub _getglob { no strict 'refs'; \*{$_[0]} }
our %MAYBE_LOADED;
+sub _load_module {
+ return 1 if $_[0]->can('can');
+ (my $proto = $_[0]) =~ s/::/\//g;
+ require "${proto}.pm";
+ return 1;
+}
+
sub _maybe_load_module {
return $MAYBE_LOADED{$_[0]} if exists $MAYBE_LOADED{$_[0]};
(my $proto = $_[0]) =~ s/::/\//g;
sub _getglob { no strict 'refs'; \*{$_[0]} }
+sub _load_module {
+ return 1 if $_[0]->can('can');
+ (my $proto = $_[0]) =~ s/::/\//g;
+ require "${proto}.pm";
+ return 1;
+}
+
sub import {
my $target = caller;
my $me = $_[0];
sub apply_role_to_package {
my ($me, $role, $to) = @_;
+ _load_module($role);
+
die "This is apply_role_to_package" if ref($to);
die "${role} is not a Role::Tiny" unless my $info = $INFO{$role};
sub create_class_with_roles {
my ($me, $superclass, @roles) = @_;
+ die "No roles supplied!" unless @roles;
+
my $new_name = join('+', $superclass, my $compose_name = join '+', @roles);
return $new_name if $COMPOSED{class}{$new_name};
foreach my $role (@roles) {
+ _load_module($role);
die "${role} is not a Role::Tiny" unless my $info = $INFO{$role};
}