forked from stevan/BreadBoard
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix stevan#43: SetterInjection allows custom constructor names
- Loading branch information
Showing
4 changed files
with
59 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package Bread::Board::Service::WithConstructor; | ||
use Moose::Role; | ||
|
||
use Try::Tiny; | ||
|
||
with 'Bread::Board::Service::WithClass'; | ||
|
||
has 'constructor_name' => ( | ||
is => 'rw', | ||
isa => 'Str', | ||
lazy => 1, | ||
builder => '_build_constructor_name', | ||
); | ||
|
||
sub _build_constructor_name { | ||
my $self = shift; | ||
|
||
try { Class::MOP::class_of($self->class)->constructor_name } || 'new'; | ||
} | ||
|
||
no Moose; 1; | ||
|
||
__END__ | ||
=pod | ||
=head1 DESCRIPTION | ||
=head1 METHODS | ||
=over 4 | ||
=item B<constructor_name> | ||
=back | ||
=head1 BUGS | ||
All complex software has bugs lurking in it, and this module is no | ||
exception. If you find a bug please either email me, or add the bug | ||
to cpan-RT. | ||
=cut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters