samsymons / RedditKit.rb

[Deprecated] A Ruby wrapper for the reddit API
https://redditkit.com/
MIT License
152 stars 26 forks source link

Options hash being modified unexpectedly #30

Closed na-g closed 9 years ago

na-g commented 9 years ago

I found it unexpected that optional parameter hashes are being modified, and keys are deleted. The specific example that was tripping me up was in Links::links. I noticed that the first set of results that were returned were from the correct ':category', and the rest were from the default.

p q_opts = {:limit=>100,:category=>:new}
#> {:limit=>100, :category=>:new}
client.links(subreddit,q_opts)
p q_opts
#>{:limit=>100}

I worked around it by cloning the hash each time I use it.