Commit | Line | Data |
6c74d087 |
1 | package Class::Tiny; |
2 | |
3 | use strictures 1; |
4 | use Class::Tiny::_Utils; |
5 | |
6 | sub import { |
7 | my $target = caller; |
de3d4906 |
8 | strictures->import; |
6c74d087 |
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; |