-
Notifications
You must be signed in to change notification settings - Fork 2
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
Provide a non-threadsafe mechanism to override registered values #9
base: master
Are you sure you want to change the base?
Conversation
Uses a simple push/pop with the current context (registry, cache, etc.) to override withing the push/pop cycle, or use `container.override { ... } ` to automatically push/pop at the beginning and end of the block. Did I say "non-threadsafe?" OVERRIDES ARE NOT THREADSAFE!
Geez. Realized I didn't commit a couple files. Fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks pretty nice; I want to give it a try with some of my projects where I override things in tests to make sure that it works as expected.
Spent a bit of time with this branch and
Expected behavior would, for me, be a raised exception since the registration was made in a pushed context.
(I should also note that doing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See main comment. (Figured I might as well turn this into a real review.)
Probable Scope Creep Initiate!
I also find the cited behavior of e.g., c[:some_key_i_havent_registered_yet]
(raising NoMethodError
and leaving junk on the stack) somewhat jarring. Surely we can act more like Hash
(which is ultimately how I conceptualize this class) or at least return a more appropriate exception class.
Uses a simple push/pop with the current context (registry, cache, etc.) to override withing the push/pop cycle, or use
container.override { ... }
to automatically push/pop at the beginning and end of the block.Did I say "non-threadsafe?" OVERRIDES ARE NOT THREADSAFE!