Skip to content

unable to create scalar bare services using references? #69

@djerius

Description

@djerius

Hi,

I'm like to create a bare service via a reference which returns a scalar. I can't seem to be able to come up with a configuration that works. Here's some code and a configuration:

use strict;
use warnings;

use Data::Dumper;
use Beam::Wire;

package Class {
    sub new { return bless {}, $_[0] }
    sub time { return 20 }
}
$INC{'Class.pm'} = 'Class.pm';    # so module looks like it's been loaded.

my %call = (
    '$ref'  => 'evt2data',
    '$call' => 'time',
);

my %config = (
    'evt2data' => {
        'class' => 'Class',
    },
    'time' => [ { %call } ],
    'time1' => { %call },
    'time2' => { value  => { %call } },
);

my $wire = Beam::Wire->new( config => \%config );

for my $service ( qw[ time time1 time2 ] ) {
    eval { say Dumper( $wire->get( $service ) ) }
      or say STDERR $@;
}

With the following output:

$VAR1 = [
          20
        ];

Invalid config for service 'time1': Service configuration incomplete. Missing one of "class", "value", "config"
$VAR1 = {
          '$ref' => 'evt2data',
          '$call' => 'time'
        };

Is what I'm asking for possible?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions