intridea/oauth2 — pull request #131 by tmhedberg (2013-03-25 20:40:05+00:00)
Title: OAuth2::Client#initialize: Avoid mutating options hash

Users of this library may assume that the `opts` hash passed as an argument to the `OAuth2::Client` initializer is not mutated during the execution of that method. If they pass a hash of options to `OAuth2::Client#new` and then proceed to use that same hash elsewhere after the call returns, they may be surprised to find several keys missing. Bugs ensue.

Whether or not the mentioned assumption is reasonable (I think it is), it is best to avoid modifying method arguments, especially when the method in question is commonly invoked across library boundaries. If we *must* mutate an argument, this should at least be well-documented, but in this case it is not.

This change prevents this problematic scenario by deleting from a clone of the hash rather than from the hash itself.