summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/MooseX/Bread/Board/Meta/Role/Attribute.pm9
-rw-r--r--t/33-constructor-name.t30
2 files changed, 39 insertions, 0 deletions
diff --git a/lib/MooseX/Bread/Board/Meta/Role/Attribute.pm b/lib/MooseX/Bread/Board/Meta/Role/Attribute.pm
index c6c1335..e44b30e 100644
--- a/lib/MooseX/Bread/Board/Meta/Role/Attribute.pm
+++ b/lib/MooseX/Bread/Board/Meta/Role/Attribute.pm
@@ -40,6 +40,12 @@ has dependencies => (
predicate => 'has_dependencies',
);
+has constructor_name => (
+ is => 'ro',
+ isa => 'Str',
+ predicate => 'has_constructor_name',
+);
+
after attach_to_class => sub {
my $self = shift;
@@ -55,6 +61,9 @@ after attach_to_class => sub {
($self->has_dependencies
? (dependencies => $self->dependencies)
: ()),
+ ($self->has_constructor_name
+ ? (constructor_name => $self->constructor_name)
+ : ()),
);
my $service;
diff --git a/t/33-constructor-name.t b/t/33-constructor-name.t
new file mode 100644
index 0000000..28647ee
--- /dev/null
+++ b/t/33-constructor-name.t
@@ -0,0 +1,30 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More;
+
+{
+ package Bar;
+
+ sub create { bless {}, shift }
+}
+
+{
+ package Foo;
+ use Moose;
+ use MooseX::Bread::Board;
+
+ has bar => (
+ is => 'ro',
+ isa => 'Bar',
+ class => 'Bar',
+ constructor_name => 'create',
+ );
+}
+
+{
+ my $foo = Foo->new;
+ isa_ok($foo->bar, 'Bar');
+}
+
+done_testing;