Add field/association level default_if option#191
Merged
Conversation
wai-procore
reviewed
Dec 19, 2019
| EMPTY_HASH = "empty_hash".freeze | ||
| EMPTY_STRING = "empty_string".freeze | ||
|
|
||
| module EmptyTypeHelper |
There was a problem hiding this comment.
wondering if this module name should be consistent with the file name empty_types.rb or vice versa?
wai-procore
approved these changes
Dec 19, 2019
wai-procore
left a comment
There was a problem hiding this comment.
one NB comment about the filepath vs module name discrepancy, otherwise lgtm
nolanprocore
approved these changes
Dec 19, 2019
philipqnguyen
suggested changes
Dec 19, 2019
| @@ -1,3 +1,3 @@ | |||
| module Blueprinter | |||
| VERSION = '0.20.0'.freeze | |||
| VERSION = '0.20.1'.freeze | |||
Contributor
There was a problem hiding this comment.
This is new feature. What do you think if we make it 0.21.0?
Also need update to CHANGELOG
Contributor
Author
There was a problem hiding this comment.
Of course, great catch!
| @@ -1,3 +1,6 @@ | |||
| ## 0.21.0 - 2019/12/19 | |||
| * 🚀 [FEATURE] Ability to specify `default_if` field/association option for more control on when the default value is applied. [191](https://github.com/procore/blueprinter/pull/191). Thanks to [@mcclayton](https://github.com/mcclayton). | |||
Contributor
Author
There was a problem hiding this comment.
Just following the template 😅
philipqnguyen
approved these changes
Dec 19, 2019
adamwells
approved these changes
Dec 19, 2019
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.
Sometimes, you may want certain "empty" values to pass through to the default value other than nil.
This PR gives Blueprinter the ability to treat the following empty types as the default value (or
nilif no default provided).Blueprinter::EMPTY_COLLECTION
An empty array or empty active record collection.
Blueprinter::EMPTY_HASH
An empty hash.
Blueprinter::EMPTY_STRING
An empty string or symbol.
Field-level/Association-level Setting