Bread-Board
view release on metacpan or search on metacpan
lib/Bread/Board/ConstructorInjection.pm view on Meta::CPAN
package Bread::Board::ConstructorInjection;
our $AUTHORITY = 'cpan:STEVAN';
# ABSTRACT: service instantiating objects via a constructor
$Bread::Board::ConstructorInjection::VERSION = '0.37';
use Moose;
use Try::Tiny;
use Bread::Board::Types;
with 'Bread::Board::Service::WithConstructor',
'Bread::Board::Service::WithParameters',
'Bread::Board::Service::WithDependencies';
has '+class' => (required => 1);
sub get {
my $self = shift;
my $constructor = $self->constructor_name;
$self->class->$constructor( %{ $self->params } );
}
__PACKAGE__->meta->make_immutable;
no Moose; 1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Bread::Board::ConstructorInjection - service instantiating objects via a constructor
=head1 VERSION
version 0.37
=head1 DESCRIPTION
This L<service|Bread::Board::Service> class instantiates objects by
calling the constructor on a class.
This class consumes L<Bread::Board::Service::WithClass>,
L<Bread::Board::Service::WithParameters>,
L<Bread::Board::Service::WithDependencies>.
=head1 ATTRIBUTES
=head2 C<class>
Attribute provided by L<Bread::Board::Service::WithClass>. This
service makes it a required attribute: you can't call a constructor if
you don't have a class.
=head2 C<constructor_name>
Optional string, indicates the name of the class method to invoke to
construct the object. If not provided, defaults to the constructor
name obtained via L<Class::MOP::Class>, or C<new> if introspection
does not work.
=head1 METHODS
( run in 2.002 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )