PoC: Isolate dependency injections by specific pattern#59
Open
davydovanton wants to merge 1 commit into
Open
Conversation
Author
rbUUbr
reviewed
May 30, 2019
|
|
||
| # @api public | ||
| def [](*dependency_names) | ||
| raise unless match_by_pattern?(dependency_names) |
There was a problem hiding this comment.
I think, it will be better to raise some fixed error, not RuntimeError. I think, it would be great for programmers. WDYT about it?
Member
|
Issues
======
- Added 4
See the complete overview on Codacy |
solnic
reviewed
Jan 4, 2020
| describe "allow" do | ||
| before do | ||
| module Test | ||
| AutoInject = Dry::AutoInject({one: 1, two: 2}) |
Member
There was a problem hiding this comment.
Issue found: Redundant curly braces around a hash parameter.
solnic
reviewed
Jan 4, 2020
| @@ -0,0 +1,34 @@ | |||
| # frozen_string_literal: true | |||
|
|
|||
| RSpec.describe "allow condition" do | |||
Member
There was a problem hiding this comment.
solnic
reviewed
Jan 4, 2020
| # frozen_string_literal: true | ||
|
|
||
| RSpec.describe "allow condition" do | ||
| describe "allow" do |
Member
There was a problem hiding this comment.
solnic
reviewed
Jan 4, 2020
| describe "allow" do | ||
| before do | ||
| module Test | ||
| AutoInject = Dry::AutoInject({one: 1, two: 2}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hey, I have a idea how to improve injector for scopes in business logic.
I create simple PR for discussing and share this idea
Idea
Imagine a situation when you have an application with 2 different scopes:
AccountsandOrders. And in each scope (or domain) you have specific operations and repositories. And in account repo we have a similar method namefind:We put all these classes into a container and now we can fail if someone injects account repo from
AccountstoOrdersscope:Important thing
This code (with injection
'accounts.repositories.accounts') raise error only after booting and first real call.For detecting these situations I introduce
allowmethod with simple regexp pattern:And now, if we will try to inject
'accounts.repositories.accounts'toOrders::Operations::Createwe fail on creating an instance of operation.Implementation
It's just a proposal of my vision. I'm not sure that
allowbetter name for this. But I'll be happy to discuss it with everyone ❤️