Bolts/Blueprint/Literal.pm

filter: Statementstmt 100% 14 / 14 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 100% 3 / 3 totaltotal 100% 22 / 22 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
builder
1.0
CRAP 1.0
« Bolts/Blueprint/Factory.pm ↑ Summary Bolts/Blueprint/ParentBag.pm »
1 package Bolts::Blueprint::Literal;
2 10 $Bolts::Blueprint::Literal::VERSION = '0.143170';
3 # ABSTRACT: A blueprint that points to a literal value
4  
5 10 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 10 with 'Bolts::Blueprint::Role::Injector';
8  
9 10 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12 10 has value => (
13 is => 'ro',
14 required => 1,
15 );
16  
17  
18 sub builder {
19 307 ▶ my ($self) = @_;
Subroutine builder: called CC=1 SCAR=0.0
Pod documented
20 307 $self->value;
21 }
22  
23  
24 18 ▶sub exists { 1 }
Subroutine exists: called CC=1 SCAR=0.0
Pod documented
25  
26  
27 578 ▶sub implied_scope { 'singleton' }
Subroutine implied_scope: called CC=1 SCAR=0.0
Pod documented
28  
29 10 __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.143170
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
« Bolts/Blueprint/Factory.pm ↑ Summary Bolts/Blueprint/ParentBag.pm »