Bolts/Artifact/Thunk.pm

filter: Statementstmt 100% 7 / 7 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 2 / 2 Podpod 100% 1 / 1 totaltotal 100% 10 / 10 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
such_that
1.0
CRAP 1.0
« Bolts/Meta/Class/Trait/Locator.pm ↑ Summary Bolts/Blueprint.pm »
1 package Bolts::Artifact::Thunk;
2 10 $Bolts::Artifact::Thunk::VERSION = '0.143170';
3 # ABSTRACT: Simplified artifact implementation
4  
5 10 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7  
8 10 has thunk => (
9 is => 'ro',
10 isa => 'CodeRef',
11 traits => [ 'Code' ],
12 handles => {
13 'get' => 'execute_method',
14 },
15 );
16  
17  
18 # TODO Fix this. Make it do something rather than ignore the check.
19 ▶sub such_that { }
Subroutine such_that: called CC=1 SCAR=0.0
Pod documented
20  
21 10 with 'Bolts::Role::Artifact';
22  
23 10 __PACKAGE__->meta->make_immutable;
24  
25 __END__
26  
27 =pod
28  
29 =encoding UTF-8
30  
31 =head1 NAME
32  
33 Bolts::Artifact::Thunk - Simplified artifact implementation
34  
35 =head1 VERSION
36  
37 version 0.143170
38  
39 =head1 SYNOPSIS
40  
41 use Bolts;
42  
43 my $artifact = Bolts::Artifact::Thunk->new(
44 thunk => sub {
45 my ($artifact, $bag, %parameters) = @_;
46 return MyApp::Thing->new(%parameters);
47 },
48 );
49  
50 =head1 DESCRIPTION
51  
52 This provides a greatly simplified implementation of L<Bolts::Role::Artifact>. This skips out on all of the main features of Bolts by just boiling the artifact definition down to the simplest possible form. There are no blueprints, no scope, no injection, just a thunk that does the work.
53  
54 This is handy for cases where a full-blown artifact implementation is tedious or impossible, particularly when bootstrapping L<Bolts::Meta::Locator>.
55  
56 It may also be used when you just need a shortcut or optimization. That said, you will probably regret any extensive use of this. (I mean, really, why bother with the Bolt framework if you just short-circuit major bits down to this? You could just implement something simpler and probably faster.)
57  
58 =head1 ROLES
59  
60 =over
61  
62 =item *
63  
64 L<Bolts::Role::Artifact>
65  
66 =back
67  
68 =head1 ATTRIBUTES
69  
70 =head2 thunk
71  
72 This is the code reference used to construct the artifact. It will be called every time the artifact is resolved.
73  
74 =head1 METHODS
75  
76 =head2 get
77  
78 This is implemented using the C<execute_method> of L<Moose::Meta::Attribute::Trait::Native::Code> on L</thunk>.
79  
80 =head2 such_that
81  
82 Not implemented.
83  
84 B<Caution:> In the future, this will probably be implemented.
85  
86 =head1 AUTHOR
87  
88 Andrew Sterling Hanenkamp <hanenkamp@cpan.org>
89  
90 =head1 COPYRIGHT AND LICENSE
91  
92 This software is copyright (c) 2014 by Qubling Software LLC.
93  
94 This is free software; you can redistribute it and/or modify it under
95 the same terms as the Perl 5 programming language system itself.
96  
97 =cut
« Bolts/Meta/Class/Trait/Locator.pm ↑ Summary Bolts/Blueprint.pm »