Closed vaukalak closed 7 years ago
:+1:
vote
:+1:
I know @darscan is hesitant to inject into existing objects, but maybe guards could be an exception?
Hi. It's a good proposal, but as @creynders mentioned I don't think it's wise to inject into existing objects - at least not from inside core framework utilities like this one. The main reason is that it's less flexible:
As it stands the choice is up to the developer: The objects can be configured to your liking (including calling injectInto
before passing through), without the injector stomping over your fields.
With the proposed change: Objects will always be injected into (even when manually configured) with no way to opt-out.
In this case, adding this feature makes the framework less flexible.
You can still achieve your use-case above by writing a compound guard utility.
@vaukalak if you need any help on writing a compound guard map let me know.
in this way, we can pass complex guard objects, for example:
withGuards(Guards.or(SomeGuard, Guards.not(SomeAnotherGuard)));