6 our $VERSION = '0.009001'; # 0.9.1
7 $VERSION = eval $VERSION;
15 return if $MAKERS{$target}; # already exported into this package
16 *{_getglob("${target}::extends")} = sub {
17 _load_module($_) for @_;
18 *{_getglob("${target}::ISA")} = \@_;
20 *{_getglob("${target}::with")} = sub {
22 die "Only one role supported at a time by with" if @_ > 1;
23 Moo::Role->apply_role_to_package($_[0], $target);
25 $MAKERS{$target} = {};
26 *{_getglob("${target}::has")} = sub {
27 my ($name, %spec) = @_;
28 ($MAKERS{$target}{accessor} ||= do {
29 require Method::Generate::Accessor;
30 Method::Generate::Accessor->new
31 })->generate_method($target, $name, \%spec);
32 $class->_constructor_maker_for($target)
33 ->register_attribute_specs($name, \%spec);
35 foreach my $type (qw(before after around)) {
36 *{_getglob "${target}::${type}"} = sub {
37 require Class::Method::Modifiers;
38 _install_modifier($target, $type, @_);
43 @{"${target}::ISA"} = do {
44 require Moo::Object; ('Moo::Object');
45 } unless @{"${target}::ISA"};
49 sub _constructor_maker_for {
50 my ($class, $target) = @_;
51 return unless $MAKERS{$target};
52 $MAKERS{$target}{constructor} ||= do {
53 require Method::Generate::Constructor;
54 Method::Generate::Constructor
57 accessor_generator => do {
58 require Method::Generate::Accessor;
59 Method::Generate::Accessor->new;
63 ->register_attribute_specs(do {
65 # using the -last- entry in @ISA means that classes created by
66 # Role::Tiny as N roles + superclass will still get the attributes
68 if (my $super = do { no strict 'refs'; ${"${target}::ISA"}[-1] }) {
69 if (my $con = $MAKERS{$super}{constructor}) {
70 @spec = %{$con->all_attribute_specs};