diff options
author | Jesse Luehrs <doy@tozt.net> | 2011-02-21 13:25:09 -0600 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2011-02-21 13:25:09 -0600 |
commit | 5067979bd1601d557362d79aa03a51665a761a39 (patch) | |
tree | 8d98a8d3c135108bb716a22e8905b838446ce609 /lib | |
parent | eb3f39183f1e1039a4d9a73cb1c2b19ea514c436 (diff) | |
download | bread-board-declare-5067979bd1601d557362d79aa03a51665a761a39.tar.gz bread-board-declare-5067979bd1601d557362d79aa03a51665a761a39.zip |
factor this out into a method
Diffstat (limited to 'lib')
-rw-r--r-- | lib/MooseX/Bread/Board/Role/Service.pm | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/MooseX/Bread/Board/Role/Service.pm b/lib/MooseX/Bread/Board/Role/Service.pm index 8442e3a..5e06eee 100644 --- a/lib/MooseX/Bread/Board/Role/Service.pm +++ b/lib/MooseX/Bread/Board/Role/Service.pm @@ -12,6 +12,18 @@ around get => sub { my $orig = shift; my $self = shift; + my $container = $self->parent_container; + + if ($self->associated_attribute->has_value($container)) { + return $self->associated_attribute->get_value($container); + } + + return $self->$orig(@_); +}; + +sub parent_container { + my $self = shift; + my $container = $self; until (!defined($container) || ($container->isa('Bread::Board::Container') @@ -20,12 +32,8 @@ around get => sub { } die "Couldn't find associated object!" unless defined $container; - if ($self->associated_attribute->has_value($container)) { - return $self->associated_attribute->get_value($container); - } - - return $self->$orig(@_); -}; + return $container; +} no Moose::Role; |