12 *{_getglob("${target}::extends")} = sub {
13 _load_module($_) for @_;
14 *{_getglob("${target}::ISA")} = \@_;
16 *{_getglob("${target}::with")} = sub {
18 die "Only one role supported at a time by with" if @_ > 1;
19 Moo::Role->apply_role_to_package($_[0], $target);
21 $MAKERS{$target} = {};
22 *{_getglob("${target}::has")} = sub {
23 my ($name, %spec) = @_;
24 ($MAKERS{$target}{accessor} ||= do {
25 require Method::Generate::Accessor;
26 Method::Generate::Accessor->new
27 })->generate_method($target, $name, \%spec);
28 $class->_constructor_maker_for($target)
29 ->register_attribute_specs($name, \%spec);
31 foreach my $type (qw(before after around)) {
32 *{_getglob "${target}::${type}"} = sub {
33 _install_modifier($target, $type, @_);
38 @{"${target}::ISA"} = do {
39 require Moo::Object; ('Moo::Object');
40 } unless @{"${target}::ISA"};
44 sub _constructor_maker_for {
45 my ($class, $target) = @_;
46 return unless $MAKERS{$target};
47 $MAKERS{$target}{constructor} ||= do {
48 require Method::Generate::Constructor;
49 Method::Generate::Constructor
52 accessor_generator => do {
53 require Method::Generate::Accessor;
54 Method::Generate::Accessor->new;
58 ->register_attribute_specs(do {
60 # using the -last- entry in @ISA means that classes created by
61 # Role::Tiny as N roles + superclass will still get the attributes
63 if (my $super = do { no strict 'refs'; ${"${target}::ISA"}[-1] }) {
64 if (my $con = $MAKERS{$super}{constructor}) {
65 @spec = %{$con->all_attribute_specs};