Beam-Wire
view release on metacpan or search on metacpan
lib/Beam/Wire.pm view on Meta::CPAN
#pod Inner containers can be nested as deeply as desired (C<foo/bar/baz/fuzz>).
#pod
#pod =cut
sub get {
my ( $self, $name, %override ) = @_;
; print STDERR "Get service: $name\n" if DEBUG;
if ( index( $name, q{/} ) != -1 ) {
my ( $container_name, $service_name ) = split m{/}, $name, 2;
my $container = $self->get( $container_name );
# This could be a Beam::Wire container, or it could be a plain hashref.
# If it's a hashref, we can automatically create a container and then use it.
if (ref $container eq 'HASH' && !(blessed $container and $container->isa('Beam::Wire'))) {
my $inner_container = Beam::Wire->new(
config => $container,
);
# Do not cache the inner container for later use, in case someone
# also tries to use the parent as a bare hashref.
lib/Beam/Wire.pm view on Meta::CPAN
#pod character to traverse through nested containers.
#pod
#pod =cut
## no critic ( ProhibitAmbiguousNames )
# This was named set() before I started using Perl::Critic, and will
# continue to be named set() now that I no longer use Perl::Critic
sub set {
my ( $self, $name, $service ) = @_;
if ( $name =~ q{/} ) {
my ( $container_name, $service_name ) = split m{/}, $name, 2;
return $self->get( $container_name )->set( $service_name, $service );
}
$self->services->{$name} = $service;
return;
}
#pod =method get_config
#pod
#pod my $conf = $wire->get_config( $name );
#pod
#pod Get the config with the given C<$name>. Like L<the get() method,
#pod above|/get>, C<$name> can contain slash (C</>) characters to traverse
#pod through nested containers.
#pod
#pod =cut
sub get_config {
my ( $self, $name ) = @_;
if ( $name =~ q{/} ) {
my ( $container_name, $service ) = split m{/}, $name, 2;
my %inner_config = %{ $self->get( $container_name )->get_config( $service ) };
# Fix relative references to prefix the container name
my ( $fixed_config ) = $self->fix_refs( $container_name, \%inner_config );
return $fixed_config;
}
return $self->config->{$name};
}
#pod =method normalize_config
#pod
( run in 1.395 second using v1.01-cache-2.11-cpan-af0e5977854 )