Initial prototype
[p5sagit/Gather-Once.git] / lib / Gather / Once.pm
CommitLineData
14342f72 1use strict;
2use warnings;
3
4package Gather::Once;
5
6use Devel::CallParser;
7
8use XSLoader;
9XSLoader::load(__PACKAGE__);
10
11use Carp 'croak';
12use Sub::Install 'install_sub';
13
14sub import {
15 my ($class, %args) = @_;
16 my $caller = caller;
17
18 use Data::Dump 'pp';
19 my $gather = sub { croak "$args{block} called as a function" };
20 my $take = sub { croak "$args{take} called as a function" };
21
22 install_sub({
23 code => $gather,
24 into => $caller,
25 as => $args{block},
26 });
27
28 install_sub({
29 code => $take,
30 into => $caller,
31 as => $args{take},
32 });
33
34 setup_gather_hook($gather, !!$args{topicalise});
35 setup_take_hook($take, [$args{topicalise}, $args{predicate}]);
36}
37
381;