| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Beam::Service; |
|
2
|
|
|
|
|
|
|
our $VERSION = '0.001'; |
|
3
|
|
|
|
|
|
|
# ABSTRACT: Role for services to access Beam::Wire features |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
#pod =head1 SYNOPSIS |
|
6
|
|
|
|
|
|
|
#pod |
|
7
|
|
|
|
|
|
|
#pod package My::Object; |
|
8
|
|
|
|
|
|
|
#pod use Role::Tiny::With; # or Moo, or Moose |
|
9
|
|
|
|
|
|
|
#pod with 'Beam::Service'; |
|
10
|
|
|
|
|
|
|
#pod |
|
11
|
|
|
|
|
|
|
#pod package main; |
|
12
|
|
|
|
|
|
|
#pod use Beam::Wire; |
|
13
|
|
|
|
|
|
|
#pod my $wire = Beam::Wire->new( |
|
14
|
|
|
|
|
|
|
#pod config => { |
|
15
|
|
|
|
|
|
|
#pod my_object => { |
|
16
|
|
|
|
|
|
|
#pod '$class' => 'My::Object', |
|
17
|
|
|
|
|
|
|
#pod }, |
|
18
|
|
|
|
|
|
|
#pod }, |
|
19
|
|
|
|
|
|
|
#pod ); |
|
20
|
|
|
|
|
|
|
#pod |
|
21
|
|
|
|
|
|
|
#pod print $wire->get( 'my_object' )->name; # my_object |
|
22
|
|
|
|
|
|
|
#pod |
|
23
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
|
24
|
|
|
|
|
|
|
#pod |
|
25
|
|
|
|
|
|
|
#pod This role adds extra functionality to an object that is going to be used |
|
26
|
|
|
|
|
|
|
#pod as a service in a L container. While any object can be |
|
27
|
|
|
|
|
|
|
#pod configured with Beam::Wire, consuming the Beam::Service role allows an |
|
28
|
|
|
|
|
|
|
#pod object to know its own name and to access the container it was |
|
29
|
|
|
|
|
|
|
#pod configured in to fetch other objects that it needs. |
|
30
|
|
|
|
|
|
|
#pod |
|
31
|
|
|
|
|
|
|
#pod =head1 SEE ALSO |
|
32
|
|
|
|
|
|
|
#pod |
|
33
|
|
|
|
|
|
|
#pod L |
|
34
|
|
|
|
|
|
|
#pod |
|
35
|
|
|
|
|
|
|
#pod =cut |
|
36
|
|
|
|
|
|
|
|
|
37
|
1
|
|
|
1
|
|
7081
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
23
|
|
|
38
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
19
|
|
|
39
|
1
|
|
|
1
|
|
4
|
use Moo::Role; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
5
|
|
|
40
|
1
|
|
|
1
|
|
708
|
use Types::Standard qw( Str InstanceOf ); |
|
|
1
|
|
|
|
|
78155
|
|
|
|
1
|
|
|
|
|
12
|
|
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
#pod =attr name |
|
43
|
|
|
|
|
|
|
#pod |
|
44
|
|
|
|
|
|
|
#pod The name of the service. This is the name used in the L |
|
45
|
|
|
|
|
|
|
#pod configuration file for this service. |
|
46
|
|
|
|
|
|
|
#pod |
|
47
|
|
|
|
|
|
|
#pod =cut |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
has name => ( |
|
50
|
|
|
|
|
|
|
is => 'ro', |
|
51
|
|
|
|
|
|
|
isa => Str, |
|
52
|
|
|
|
|
|
|
); |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
#pod =attr container |
|
55
|
|
|
|
|
|
|
#pod |
|
56
|
|
|
|
|
|
|
#pod The L container object that contained this service. Using |
|
57
|
|
|
|
|
|
|
#pod this container we can get other services as-needed. |
|
58
|
|
|
|
|
|
|
#pod |
|
59
|
|
|
|
|
|
|
#pod =cut |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
has container => ( |
|
62
|
|
|
|
|
|
|
is => 'ro', |
|
63
|
|
|
|
|
|
|
isa => InstanceOf['Beam::Wire'], |
|
64
|
|
|
|
|
|
|
); |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |