line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bread::Board::Literal; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:STEVAN'; |
3
|
|
|
|
|
|
|
# ABSTRACT: service providing a literal value |
4
|
|
|
|
|
|
|
$Bread::Board::Literal::VERSION = '0.37'; |
5
|
62
|
|
|
62
|
|
5360
|
use Moose; |
|
62
|
|
|
|
|
134
|
|
|
62
|
|
|
|
|
2548
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
with 'Bread::Board::Service'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has 'value' => ( |
10
|
|
|
|
|
|
|
is => 'rw', |
11
|
|
|
|
|
|
|
required => 1, |
12
|
|
|
|
|
|
|
); |
13
|
|
|
|
|
|
|
|
14
|
141
|
|
|
141
|
1
|
3880
|
sub get { (shift)->value } |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub clone_and_inherit_params { |
17
|
1
|
|
|
1
|
1
|
124
|
confess 'Trying to inherit from a literal service'; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
21
|
|
|
|
|
|
|
|
22
|
62
|
|
|
62
|
|
423542
|
no Moose; 1; |
|
62
|
|
|
|
|
148
|
|
|
62
|
|
|
|
|
373
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
__END__ |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=pod |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=encoding UTF-8 |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 NAME |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Bread::Board::Literal - service providing a literal value |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 VERSION |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
version 0.37 |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 SYNOPSIS |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my $c = container PrettyBoring => as { |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# These are Bread::Board::Literal services |
43
|
|
|
|
|
|
|
service connect_string => 'dbi:mysql:boring_db'; |
44
|
|
|
|
|
|
|
service service_url => 'http://api.example.com/v0/boring'; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# And some other services depending on them... |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
service dbconn => ( |
49
|
|
|
|
|
|
|
class => 'DBI', |
50
|
|
|
|
|
|
|
block => sub { |
51
|
|
|
|
|
|
|
my $s = shift; |
52
|
|
|
|
|
|
|
DBI->new($s->param('connect_string'); |
53
|
|
|
|
|
|
|
}, |
54
|
|
|
|
|
|
|
dependencies => wire_names(qw( connect_string )), |
55
|
|
|
|
|
|
|
); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
service service_request => ( |
58
|
|
|
|
|
|
|
class => 'HTTP::Request', |
59
|
|
|
|
|
|
|
block => sub { |
60
|
|
|
|
|
|
|
my $s = shift; |
61
|
|
|
|
|
|
|
HTTP::Request->new(POST => $s->param('service_url')); |
62
|
|
|
|
|
|
|
}, |
63
|
|
|
|
|
|
|
dependencies => wire_names(qw( service_url )); |
64
|
|
|
|
|
|
|
}; |
65
|
|
|
|
|
|
|
}; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# OR to use directly: |
68
|
|
|
|
|
|
|
my $literal = Bread::Board::Literal->new( |
69
|
|
|
|
|
|
|
name => 'the_answer_to_life_the_universe_and_everything', |
70
|
|
|
|
|
|
|
value => 42, |
71
|
|
|
|
|
|
|
); |
72
|
|
|
|
|
|
|
$c->add_service($literal); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 DESCRIPTION |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
A literal service is one that stores a literal scalar or reference for use in |
77
|
|
|
|
|
|
|
your Bread::Board. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Beware of using references in your literals as they may cause your Bread::Board |
80
|
|
|
|
|
|
|
to leak memory. If this is a concern, you may want to weaken your references. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
See L<Scalar::Util/weaken>. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 C<value> |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Required attribute with read/write accessor. This is the value that |
89
|
|
|
|
|
|
|
L</get> will return. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 METHODS |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 C<get> |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Returns the L</value>, unaltered. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 C<clone_and_inherit_params> |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Dies: a literal service is (essentially) a constant, it does not make |
100
|
|
|
|
|
|
|
sense to inherit from it. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 AUTHOR |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Stevan Little <stevan@iinteractive.com> |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 BUGS |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Please report any bugs or feature requests on the bugtracker website |
109
|
|
|
|
|
|
|
https://github.com/stevan/BreadBoard/issues |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
When submitting a bug or request, please include a test-file or a |
112
|
|
|
|
|
|
|
patch to an existing test-file that illustrates the bug or desired |
113
|
|
|
|
|
|
|
feature. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
This software is copyright (c) 2019, 2017, 2016, 2015, 2014, 2013, 2011, 2009 by Infinity Interactive. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
120
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=cut |