summaryrefslogtreecommitdiffstats
path: root/lib/Bread
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2011-09-29 13:12:45 -0500
committerJesse Luehrs <doy@tozt.net>2011-09-29 13:12:45 -0500
commitc513dd3113943da6b6d1b42203d18a2bbb908de1 (patch)
tree3c40292a05df3d03d72411201f48c5598119ad1b /lib/Bread
parent3d719db0faf9c9b5ada4973b8225d9927ed968f7 (diff)
downloadbread-board-declare-c513dd3113943da6b6d1b42203d18a2bbb908de1.tar.gz
bread-board-declare-c513dd3113943da6b6d1b42203d18a2bbb908de1.zip
allow specifying dependencies inline
Diffstat (limited to 'lib/Bread')
-rw-r--r--lib/Bread/Board/Declare.pm29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/Bread/Board/Declare.pm b/lib/Bread/Board/Declare.pm
index 404a427..3f5dff5 100644
--- a/lib/Bread/Board/Declare.pm
+++ b/lib/Bread/Board/Declare.pm
@@ -117,6 +117,7 @@ become services, as in:
=cut
my (undef, undef, $init_meta) = Moose::Exporter->build_import_methods(
+ as_is => ['dep'],
install => ['import', 'unimport'],
class_metaroles => {
attribute => ['Bread::Board::Declare::Meta::Role::Attribute'],
@@ -145,6 +146,34 @@ sub init_meta {
$package->$init_meta(%options);
}
+sub dep {
+ if (@_ > 1) {
+ my %opts = (
+ name => '__ANON__',
+ @_,
+ );
+
+ if (exists $opts{dependencies}) {
+ confess("Dependencies are not supported for inline services");
+ }
+
+ if (exists $opts{value}) {
+ return Bread::Board::Literal->new(%opts);
+ }
+ elsif (exists $opts{block}) {
+ return Bread::Board::BlockInjection->new(%opts);
+ }
+ elsif (exists $opts{class}) {
+ return Bread::Board::ConstructorInjection->new(%opts);
+ }
+ else {
+ }
+ }
+ else {
+ return Bread::Board::Dependency->new(service_path => $_[0]);
+ }
+}
+
=head1 BUGS
No known bugs.