line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bolts::Blueprint::Literal; |
2
|
|
|
|
|
|
|
$Bolts::Blueprint::Literal::VERSION = '0.143171'; |
3
|
|
|
|
|
|
|
# ABSTRACT: A blueprint that points to a literal value |
4
|
|
|
|
|
|
|
|
5
|
11
|
|
|
11
|
|
48
|
use Moose; |
|
11
|
|
|
|
|
13
|
|
|
11
|
|
|
|
|
73
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
with 'Bolts::Blueprint::Role::Injector'; |
8
|
|
|
|
|
|
|
|
9
|
11
|
|
|
11
|
|
51027
|
use Carp (); |
|
11
|
|
|
|
|
20
|
|
|
11
|
|
|
|
|
986
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has value => ( |
13
|
|
|
|
|
|
|
is => 'ro', |
14
|
|
|
|
|
|
|
required => 1, |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub builder { |
19
|
313
|
|
|
313
|
1
|
320
|
my ($self) = @_; |
20
|
313
|
|
|
|
|
7870
|
$self->value; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
18
|
|
|
18
|
1
|
42
|
sub exists { 1 } |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
590
|
|
|
590
|
1
|
1396
|
sub implied_scope { 'singleton' } |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
__END__ |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=pod |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=encoding UTF-8 |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 NAME |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Bolts::Blueprint::Literal - A blueprint that points to a literal value |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 VERSION |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
version 0.143171 |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 SYNOPSIS |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
use Bolts; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# The usual sugar |
50
|
|
|
|
|
|
|
artifact thing1 => 42; |
51
|
|
|
|
|
|
|
artifact thing2 => ( value => 42 ); |
52
|
|
|
|
|
|
|
artifact thing3 => ( |
53
|
|
|
|
|
|
|
value => [ 'this', 'is', 'an', 'example' ], |
54
|
|
|
|
|
|
|
); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# Or directly... |
57
|
|
|
|
|
|
|
my $meta = Bolts::Bag->start_bag; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
my $artifact = Bolts::Artifact->new( |
60
|
|
|
|
|
|
|
name => 'thing', |
61
|
|
|
|
|
|
|
blueprint => $meta->locator->acquire('blueprint', 'literal', { |
62
|
|
|
|
|
|
|
value => 42, |
63
|
|
|
|
|
|
|
}, |
64
|
|
|
|
|
|
|
scope => $meta->locator->acquire('scope', '_'), |
65
|
|
|
|
|
|
|
); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 DESCRIPTION |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Provides a blueprint that points to a single value. This is best used for scalars, strings, and numbers, but could be used for references. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
B<Caveat.> In the case of references, the same reference is returned every time so the contents of that reference might be modified by anyone that acquires it. This may be desirable in your application, but there's the warning in case it is not. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 ROLES |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=over |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=item * |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
L<Bolts::Blueprint::Role::Injector> |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=back |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 value |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This is the literal value to return when this blueprint is resolved. This can be anything you can assign to a scalar variable, including references to arrays and hash (see the caveat above). |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 METHODS |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 builder |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Returns the L</value>. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head2 exists |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Always returns true. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 implied_scope |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
This is set. A literal blueprint value acts like a global singleton. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 AUTHOR |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Andrew Sterling Hanenkamp <hanenkamp@cpan.org> |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
This software is copyright (c) 2014 by Qubling Software LLC. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
112
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=cut |