| 1 | package Bread::Board::ConstructorInjection; | ||
| 2 | 63 | our $AUTHORITY = 'cpan:STEVAN'; | |
| 3 | # ABSTRACT: service instantiating objects via a constructor | ||
| 4 | 63 | $Bread::Board::ConstructorInjection::VERSION = '0.37'; | |
| 5 | 63 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 63 | ▶ | use Try::Tiny; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 63 | ▶ | use Bread::Board::Types; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | 63 | with 'Bread::Board::Service::WithConstructor', | |
| 12 | 'Bread::Board::Service::WithParameters', | ||
| 13 | 'Bread::Board::Service::WithDependencies'; | ||
| 14 | |||
| 15 | 63 | has '+class' => (required => 1); | |
| 16 | |||
| 17 | 161 | ▶ | sub get { |
|
Subroutine
get: called CC=1 SCAR=0.0
| |||
| 18 | 161 | my $self = shift; | |
| 19 | |||
| 20 | 161 | my $constructor = $self->constructor_name; | |
| 21 | 161 | $self->class->$constructor( %{ $self->params } ); | |
| 22 | } | ||
| 23 | |||
| 24 | 63 | __PACKAGE__->meta->make_immutable; | |
| 25 | |||
| 26 | 63 | ▶ | no Moose; 1; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 27 | |||
| 28 | __END__ | ||