robotlegs / robotlegs-framework

An ActionScript 3 application framework for Flash and Flex
https://robotlegs.tenderapp.com/
MIT License
967 stars 261 forks source link

Update guardsApprove.as #159

Closed vaukalak closed 7 years ago

vaukalak commented 10 years ago

in this way, we can pass complex guard objects, for example:

withGuards(Guards.or(SomeGuard, Guards.not(SomeAnotherGuard)));

profelis commented 10 years ago

:+1:

ivan-shaban commented 10 years ago

vote

fljot commented 10 years ago

:+1:

creynders commented 10 years ago

I know @darscan is hesitant to inject into existing objects, but maybe guards could be an exception?

darscan commented 10 years ago

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.

creynders commented 10 years ago

@vaukalak if you need any help on writing a compound guard map let me know.