c36c3ec16de8884acbb8a5e6b0ac4c945ef8a0ab
[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   strictures->import;
9   *{_getglob("${target}::extends")} = sub {
10     *{_getglob("${target}::ISA")} = \@_;
11   };
12   *{_getglob("${target}::with")} = sub {
13     require Role::Tiny;
14     die "Only one role supported at a time by with" if @_ > 1;
15     Role::Tiny->apply_role_to_package($_[0], $target);
16   };
17   foreach my $type (qw(before after around)) {
18     *{_getglob "${target}::${type}"} = sub {
19       _install_modifier($target, $type, @_);
20     };
21   }
22   {
23     no strict 'refs';
24     @{"${target}::ISA"} = do {
25       require Class::Tiny::Object; ('Class::Tiny::Object');
26     } unless @{"${target}::ISA"};
27   }
28 }
29
30 1;