line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Beam::Wire::Moose; |
2
|
|
|
|
|
|
|
$Beam::Wire::Moose::VERSION = '0.004'; |
3
|
1
|
|
|
1
|
|
26144
|
use Moose; |
|
1
|
|
|
|
|
492550
|
|
|
1
|
|
|
|
|
7
|
|
4
|
1
|
|
|
1
|
|
7039
|
use Moose::Meta::Class; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
222
|
|
5
|
|
|
|
|
|
|
extends 'Beam::Wire'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
around create_service => sub { |
8
|
|
|
|
|
|
|
my ( $orig, $self, $name, %service_info ) = @_; |
9
|
|
|
|
|
|
|
if ( my $roles = $service_info{with} ) { |
10
|
|
|
|
|
|
|
my @args = $self->parse_args( %service_info ); |
11
|
|
|
|
|
|
|
my @roles = ref $roles eq 'ARRAY' ? @{$roles} : $roles; |
12
|
|
|
|
|
|
|
my $meta = Moose::Meta::Class->create_anon_class( |
13
|
|
|
|
|
|
|
superclasses => [ $service_info{class} ], |
14
|
|
|
|
|
|
|
roles => \@roles, |
15
|
|
|
|
|
|
|
cache => 1, |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
$service_info{class} = $meta->name; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
return $self->$orig( $name, %service_info ); |
20
|
|
|
|
|
|
|
}; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
1; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
__END__ |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=pod |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 NAME |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Beam::Wire::Moose |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 VERSION |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
version 0.004 |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 SYNOPSIS |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# container.yml |
39
|
|
|
|
|
|
|
db: |
40
|
|
|
|
|
|
|
class: My::Database |
41
|
|
|
|
|
|
|
with: |
42
|
|
|
|
|
|
|
- My::Role::Cache |
43
|
|
|
|
|
|
|
- My::Role::Log |
44
|
|
|
|
|
|
|
args: |
45
|
|
|
|
|
|
|
dbh: { ref: dbh } |
46
|
|
|
|
|
|
|
dbh: |
47
|
|
|
|
|
|
|
class: DBI |
48
|
|
|
|
|
|
|
args: |
49
|
|
|
|
|
|
|
- 'dbi:sqlite:data.db' |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 DESCRIPTION |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Beam::Wire::Moose is a subclass of Beam::Wire that adds support for Moose-specific |
54
|
|
|
|
|
|
|
features. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 NAME |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Beam::Wire::Moose - Dependency Injection with extra Moose features |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 SERVICE CONFIG |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 with |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Compose roles into this object at run-time. This creates an anonymous class that |
65
|
|
|
|
|
|
|
extends the C<class> config and consumes the roles defined by C<with>. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
NOTE: This means the service is not an instance of C<class> but an instance of |
68
|
|
|
|
|
|
|
a class that inherits from C<class>. Be cautious when using C<ref> and |
69
|
|
|
|
|
|
|
C<Scalar::Util::blessed>. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 SEE ALSO |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=over 4 |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=item L<Beam::Wire> |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=back |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 AUTHOR |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Doug Bell <preaction@cpan.org> |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Doug Bell. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
88
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |