Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use $ for meta-tags everywhere #43

Closed
preaction opened this issue Jan 29, 2015 · 6 comments
Closed

Use $ for meta-tags everywhere #43

preaction opened this issue Jan 29, 2015 · 6 comments
Labels

Comments

@preaction
Copy link
Owner

We've got two weird things:

  1. When declaring a service, we use "class", "args", "method", "sub", etc... but when declaring a dependency, we use "$class", "$args", "$method", "$sub", etc... I think we should use the "$prefix" version everywhere.

  2. If we do that, we don't need to use "$args" if the object's constructor takes key-value arguments.

myobj:
    class: MyObject
    args:
        foo: bar
        baz: fuzz

Would become:

myobj:
    $class: MyObject
    foo: bar
    baz: fuzz

And $args only needs to be dragged out when it isn't key/value pairs (an array, arraryref, or hashref)

@preaction
Copy link
Owner Author

We could have both work, in theory. In the "service" case, if we see a prefixed attribute, it's the new syntax. In the "dependency" case, if we see an unprefixed attribute, it's the new syntax.

We should probably avoid supporting it forever, bu I'm not sure... I hate having to update because dependencies...

@preaction
Copy link
Owner Author

There are some edge cases to consider:

plugin:
    baz:
        $class: My::Plugin::Baz
    foo:
        $class: My::Plugin::Foo
    class:
        $class: My::Plugin::Class

If I ask for $wire->get( 'plugin' ), should it try to instanciate it? It has a class, but it also has other, unknown stuff...

There are also straight-up ambiguities. But we don't want to get into a Makefile situation...

I'm tempted to, if someone reports a problem, allow a backcompat option to the constructor that will allow old containers to work.

@preaction
Copy link
Owner Author

I think if we're extremely careful and precise and well-tested, we can make this work, and then remove it for 2.0

@preaction preaction changed the title Simplify the service description: Remove the need for "args:" in certain cases Use $ for meta-tags everywhere Mar 2, 2015
@preaction
Copy link
Owner Author

I don't like the ambiguity of mixing meta tags and non-meta tags, so just force meta tags everywhere.

This means that plain values do not need a meta tag. We might be able to repurpose $path then...

@preaction
Copy link
Owner Author

I've flip-flopped on mixing meta and non-meta tags, because allowing multiple ways of specifying a service is nice. In this example, we can specify a service as a string, as a hashref, or as a full object.

source: /foo/bar/baz
source:
    url: /foo/bar/baz
source:
    $class: Cradle::Source::Svn
    url: /foo/bar/baz
# script.pl
my $wire = Beam::Wire->new( ... );
my $source = $wire->get( 'source' );
if ( !ref $source ) {
    $source = Cradle::Source::Git->new( url => $source );
}
elsif ( !blessed $source ) {
    $source = Cradle::Source::Git->new( %$source );
}

This makes the config files more powerful and easier to write for end-users.

@preaction
Copy link
Owner Author

Turns out, we can support this new way and the old way at the same time. There are likely some ambiguities, but we'll address those as they come up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant