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

Explicitly stringify the values for pun_custom_env #33

Merged
merged 3 commits into from
Apr 11, 2019

Conversation

MorganRodgers
Copy link
Contributor

Fixes error where integer values for pun_custom_env would cause TypeErrors: "no implicit conversion of Integer into String".

Fixes #26.

Fixes error where integer values for pun_custom_env would cause TypeErrors: "no implicit conversion of Integer into String".
@@ -72,7 +72,7 @@ module Configuration
attr_writer :pun_custom_env

def pun_custom_env
transform_keys(@pun_custom_env) { |key| key.to_s }
Hash[@pun_custom_env.map {|key, value| [key.to_s, value.to_s]}]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be slightly more readable if the helper method was:

transform_keys_and_values_to_strings(@pun_custom_env)

and the separate method

def transform_keys_and_values_to_strings(obj)
  Hash[obj.map {|key, value| [key.to_s, value.to_s]}]
end

Or a comment? Of course we have more complex transformations than this that don't have comments that I've written in the past so...

Copy link
Contributor Author

@MorganRodgers MorganRodgers Apr 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I elected to remove the other method because it was only used in this one method. It seems unnecessary to shift the main implementation of pun_custom_env to another method if there is no present need to make that section of code re-usable. I am open to the argument that a method to ensure that a Hash's keys and values are strings is useful, but then I question: is NginxStage::Configuration the correct place for such a thing?

@MorganRodgers MorganRodgers merged commit acb8c9f into master Apr 11, 2019
@MorganRodgers MorganRodgers deleted the fix-type-error branch April 11, 2019 13:49
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

Successfully merging this pull request may close these issues.

2 participants