core: preserve prototype methods #844
Closed
+39
−2
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.
Before:
After:
This used to work, so what happened? Well, I broke it.
When a user does:
It prepares instances of the various modules (Storage, PubSub, etc) and then extends them so that static methods are picked up (Datastore.int, Storage.acl, etc). We have methods that are the same name as static methods, eg
Datastore.dataset
andDatastore.prototype.dataset
so that if a user has an instance of a Datastore, they can access a properly scoped dataset. If they don't have an instance of a Datastore -- if they just didrequire('gcloud')
without instantiating it with config options at that time --Datastore.dataset
will require configuration details, since you haven't given them anywhere else yet.So, the fix in this PR preserves the prototype methods, not letting the static ones overwrite them.
// @callmehiphop -- need your help, buddy! Is this just madness?