Conversation
…in if_absent and just_one
Contributor
Author
|
@yegor256 take a look please, happy to clarify anything about the change. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The object that
Fbe.if_absentandFbe.just_onepass to their block kept the values in a Hash, so assigning the same property twice silently dropped the first value. A real fact would keep both, and both helpers already refuse an Array because they match by one value per property.A second assignment to a property now raises
Fbe::Error, naming the property, the new value and the one it already has, and nothing is inserted. The tests cover both the error and the empty factbase afterwards, for each helper.To keep the complexity of both methods where it was, the empty string check next to the new line is written as
v == ''instead ofv.is_a?(String) && v.empty?. It means the same and has one branch less. The perceived complexity ofif_absentis still 17 of 15, exactly as on master; this change does not touch that.Closes #1244