use Role::Tiny ();
use base qw(Role::Tiny);
+our $VERSION = '1.003001';
+$VERSION = eval $VERSION;
+
require Moo::sification;
BEGIN { *INFO = \%Role::Tiny::INFO }
}
$INFO{$target} ||= {};
# get symbol table reference
- my $stash = do { no strict 'refs'; \%{"${target}::"} };
+ my $stash = _getstash($target);
_install_tracked $target => has => sub {
- my ($name_proto, %spec) = @_;
- my $name_isref = ref $name_proto eq 'ARRAY';
- foreach my $name ($name_isref ? @$name_proto : $name_proto) {
- my $spec_ref = $name_isref ? +{%spec} : \%spec;
+ my $name_proto = shift;
+ my @name_proto = ref $name_proto eq 'ARRAY' ? @$name_proto : $name_proto;
+ if (@_ % 2 != 0) {
+ require Carp;
+ Carp::croak("Invalid options for " . join(', ', map "'$_'", @name_proto)
+ . " attribute(s): even number of arguments expected, got " . scalar @_)
+ }
+ my %spec = @_;
+ foreach my $name (@name_proto) {
+ my $spec_ref = @name_proto > 1 ? +{%spec} : \%spec;
($INFO{$target}{accessor_maker} ||= do {
require Method::Generate::Accessor;
Method::Generate::Accessor->new
}
require Class::Method::Modifiers if @$mods;
$INFO{$role}{inhaled_from_moose} = 1;
+ $INFO{$role}{is_role} = 1;
}
}
sub create_class_with_roles {
my ($me, $superclass, @roles) = @_;
- my $new_name = join(
- '__WITH__', $superclass, my $compose_name = join '__AND__', @roles
- );
+ my ($new_name, $compose_name) = $me->_composite_name($superclass, @roles);
return $new_name if $Role::Tiny::COMPOSED{class}{$new_name};
die "${role} is not a Role::Tiny" unless $INFO{$role};
}
- $Moo::MAKERS{$new_name} = {};
+ $Moo::MAKERS{$new_name} = {is_class => 1};
$me->_handle_constructor($new_name, $_) for @roles;
}
1;
+__END__
=head1 NAME
=head1 COPYRIGHT AND LICENSE
See L<Moo> for the copyright and license.
+
+=cut