Skip to content
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

#push and #insert_all mutate their original input #6

Open
benjaminjackson opened this issue Sep 10, 2017 · 0 comments
Open

#push and #insert_all mutate their original input #6

benjaminjackson opened this issue Sep 10, 2017 · 0 comments

Comments

@benjaminjackson
Copy link

benjaminjackson commented Sep 10, 2017

The #process_kpi method mutates the original options hash, which can cause unexpected results if the calling function isn't aware of this detail:

options.delete_if { |k, _| [:date, 'date'].include?(k) }
%i{key value}.each do |k|
raise("Missing '#{k}'") if (options[k] || options[k.to_s]).nil?
end
options["$#{(options['key'] || options[:key])}"] = options['value'] || options[:value]
options.delete_if { |k, _| [:key, 'key', :value, 'value'].include?(k) }
attributes = options[:attributes] || options['attributes']
unless attributes.nil?
[:attributes, 'attributes'].each {|k| options.delete(k) }
attributes.each { |k,v| options[k] = v }
end
options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant