Commit | Line | Data |
---|---|---|
22e75839 | 1 | package Object::Inline; |
2 | ||
3 | use strictures 1; | |
4 | use Package::Variant (); | |
5 | use Import::Into; | |
6 | ||
7 | sub import { | |
8 | my $class = shift; | |
9 | my $target = caller; | |
10 | Package::Variant->import::into( | |
11 | $target, | |
12 | no_import => 1, make_variant => sub { $_[2]->($_[1]) }, | |
13 | @_, | |
14 | ); | |
15 | no strict 'refs'; | |
16 | *{"${target}::object"} = sub (&;@) { | |
17 | my $code = shift; | |
18 | Package::Variant->build_variant_of($target, $code)->new(@_); | |
19 | }; | |
20 | } | |
21 | ||
22 | 1; |