1bc127c6652bd73a234b4f99b3ec5d1e49e8c72f
[gitmo/Moo.git] / lib / Class / Tiny.pm
1 package Class::Tiny;
2
3 use strictures 1;
4 use Class::Tiny::_Utils;
5
6 sub import {
7   my $target = caller;
8   *{_getglob("${target}::extends")} = sub {
9     *{_getglob("${target}::ISA")} = \@_;
10   };
11   *{_getglob("${target}::with")} = sub {
12     require Role::Tiny;
13     die "Only one role supported at a time by with" if @_ > 1;
14     Role::Tiny->apply_role_to_package($_[0], $target);
15   };
16   foreach my $type (qw(before after around)) {
17     *{_getglob "${target}::${type}"} = sub {
18       _install_modifier($target, $type, @_);
19     };
20   }
21   {
22     no strict 'refs';
23     @{"${target}::ISA"} = do {
24       require Class::Tiny::Object; ('Class::Tiny::Object');
25     } unless @{"${target}::ISA"};
26   }
27 }
28
29 1;