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

added ability to resolve with parameters at the same time #417

Merged
merged 7 commits into from
Oct 17, 2018

Conversation

josephmancuso
Copy link
Member

@josephmancuso josephmancuso commented Oct 6, 2018

This PR adds the ability to have a little bit more improved resolving process if we want to pass in dependencies from other places of our code via the resolving method of the container.

For example let's say we have this:

from masonite.request import Request

def obj(var1, request: Request, var2)
    pass

now let's say we want to resolve the request class but do NOT want to resolve the other 2 variables. Instead we want to pass them via the resolve method:

container.resolve(obj, 'test1', 'test2')

Now when resolving it will fetch the test1 and insert it in the first instance of var1 in the parameter list, then see the request: Request and resolve that as normal and then see the var2 and then inject test2 into that.

It does not need to be in any particular order (although you prob should keep resolving to the back for cleanliness.)

As long as you have the correct amount of dependencies specified via the resolve method and resolving methods then you should be good.

Note this only works when resolving parameters is turned off (which it is by default in 2.1)

@josephmancuso josephmancuso added next major Issue scheduled for the next major release beta-3 Labels the issue with which beta version this issue applies to labels Oct 6, 2018
@josephmancuso josephmancuso self-assigned this Oct 6, 2018
@josephmancuso josephmancuso changed the title added ability to resolve with parameters added ability to resolve with parameters at the same time Oct 6, 2018
@coveralls
Copy link

coveralls commented Oct 6, 2018

Coverage Status

Coverage decreased (-0.1%) to 90.461% when pulling 2e44493 on add-better-resolving into b29392f on develop.

@josephmancuso josephmancuso requested a review from a team October 7, 2018 03:59
@josephmancuso josephmancuso added this to Needs review in Masonite Beta 3 Oct 12, 2018
@josephmancuso josephmancuso merged commit 0947fae into develop Oct 17, 2018
Masonite Beta 3 automation moved this from Needs review to Done Oct 17, 2018
@josephmancuso josephmancuso deleted the add-better-resolving branch October 18, 2018 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-3 Labels the issue with which beta version this issue applies to next major Issue scheduled for the next major release
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants