Make version attribute a plain String #107
Merged
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.
This is a fix for #106. It looks fairly simple so I thought I’d do a quick PR.
When splitting the hash into the components to populate the attributes in
Password
the salt and hash were being converted into plain strings withto_str
, but the version wasn’t. This was causing problems when trying to use==
on that attribute (a change to Psych to how strings are serialized to Yaml does this).This fix just adds a call to
to_str
to the version, to match the salt and hash (the cost is converted withto_i
) and adds a matching spec.As an aside: This fixes the immediate issue. Dumping a
Password
to Yaml now looks something like this:which is what it looked like in Ruby 2.1 (or more accurately with the version of Psych in Ruby 2.1). The version, cost, salt and checksum are all duplicated. Is it worth adding
init_with
andencode_with
methods to avoid this repetition?