Beam-Wire
view release on metacpan or search on metacpan
lib/Beam/Wire.pm view on Meta::CPAN
return $_[0];
},
);
#pod =attr config
#pod
#pod The raw configuration data. By default, this data is loaded by
#pod L<Config::Any|Config::Any> using the file specified by the L<file attribute|/file>.
#pod
#pod See L<Beam::Wire::Help::Config for details on what the configuration
#pod data structure looks like|Beam::Wire::Help::Config>.
#pod
#pod If you don't want to load a file, you can specify this attribute in the
#pod Beam::Wire constructor.
#pod
#pod =cut
has config => (
is => 'ro',
isa => HashRef,
lazy => 1,
lib/Beam/Wire.pm view on Meta::CPAN
Defaults to using the directory which contains the file specified by the
L<file attribute|/file> followed by the C<BEAM_PATH> environment variable
(separated by colons C<:>).
=head2 config
The raw configuration data. By default, this data is loaded by
L<Config::Any|Config::Any> using the file specified by the L<file attribute|/file>.
See L<Beam::Wire::Help::Config for details on what the configuration
data structure looks like|Beam::Wire::Help::Config>.
If you don't want to load a file, you can specify this attribute in the
Beam::Wire constructor.
=head2 services
A hashref of cached services built from the L<configuration|/config>. If
you want to inject a pre-built object for other services to depend on,
add it here.
t/service/config.t view on Meta::CPAN
subtest 'config is relative to container dir attribute' => sub {
my $wire = Beam::Wire->new(
file => $SHARE_DIR->child( 'with_config.yml' )->relative( cwd )->stringify,
);
my $svc;
lives_ok { $svc = $wire->get( 'yaml' ) };
cmp_deeply $svc, $EXPECT;
};
subtest 'config looks in multiple directories' => sub {
my $wire = Beam::Wire->new(
dir => [$SHARE_DIR->child('beam_path'), $SHARE_DIR],
file => $SHARE_DIR->child( 'with_config.yml' )->relative( cwd )->stringify,
);
my $svc;
lives_ok { $svc = $wire->get( 'yaml' ) };
cmp_deeply $svc, { foo => 'OVERRIDDEN' };
};
t/service/ref.t view on Meta::CPAN
use Test::Exception;
use Test::Lib;
use Scalar::Util qw( refaddr );
use Beam::Wire;
{
package TestClass;
sub new { return bless {}, $_[0] }
sub greeting { return 'Hello, World' }
}
$INC{'TestClass.pm'} = 'TestClass.pm'; # so module looks like it's been loaded.
subtest 'ref service: $call' => sub {
my $wire = Beam::Wire->new(
config => {
klass => {
'$class' => 'TestClass',
},
greeting => {
'$ref' => 'klass',
( run in 2.059 seconds using v1.01-cache-2.11-cpan-5e09290becf )