Rename the enum_prefix and enum_suffix options to _prefix and _suffix#20999
Merged
kaspth merged 1 commit intorails:masterfrom Jul 23, 2015
robin850:enum-prefix-suffix
Merged
Rename the enum_prefix and enum_suffix options to _prefix and _suffix#20999kaspth merged 1 commit intorails:masterfrom robin850:enum-prefix-suffix
kaspth merged 1 commit intorails:masterfrom
robin850:enum-prefix-suffix
Conversation
This makes it more clear that they are reserved keywords and also it seems less redundant as the line already starts with the call to the `enum` method.
kaspth
added a commit
that referenced
this pull request
Jul 23, 2015
Rename the enum_prefix and enum_suffix options to _prefix and _suffix
Contributor
|
Sweet, thanks! Have a nice day too 😄 |
Member
Author
|
Thanks! :-) |
Member
There was a problem hiding this comment.
We can probably ✂️ now? Seems unlikely that people would try to use _ names, so while it's technically still true, it is just adding noise to me. What do you think?
Would trade that with an example of the feature. It doesn't really explain what the feature does, if you didn't know about the history here it seems unlikely that you would understand what it does/why you would need it from reading the docs here
Member
There was a problem hiding this comment.
to define multiple enums with same values
would be nice if the examples actually show that use case 😄
Member
Author
There was a problem hiding this comment.
Yes, you're totally right! 👍 Will send a patch then!
robin850
added a commit
that referenced
this pull request
Jul 23, 2015
The note regarding the `_prefix` and `_suffix` options is no longer useful since they were renamed specifically for this purpose. Also the given example doesn't show what these options enable and in which case they are really useful (when there are conflicting values for instance). Refs #20999. [Godfrey Chan & Robin Dupret]
y-yagi
added a commit
to y-yagi/rails
that referenced
this pull request
May 29, 2016
… skip] `:enum_prefix` and `:enum_suffix` was changed to `:_prefix` and `:_suffix` in rails#20999.
kamipo
added a commit
to kamipo/rails
that referenced
this pull request
Feb 19, 2021
Unlike other features built on Attribute API, reserved options for `enum` has leading `_`. * `_prefix`/`_suffix`: rails#19813, rails#20999 * `_scopes`: rails#34605 * `_default`: rails#39820 That is due to `enum` takes one hash argument only, which contains both enum definitions and reserved options. I propose new syntax for `enum` to avoid leading `_` from reserved options, by allowing `enum(attr_name, ..., **options)` more Attribute API like syntax. Before: ```ruby class Book < ActiveRecord::Base enum status: [ :proposed, :written ], _prefix: true, _scopes: false enum cover: [ :hard, :soft ], _suffix: true, _default: :hard end ``` After: ```ruby class Book < ActiveRecord::Base enum :status, [ :proposed, :written ], prefix: true, scopes: false enum :cover, [ :hard, :soft ], suffix: true, default: :hard end ```
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.
Hello,
This pull request renames the
enum_{prefix_suffix}options to_{prefix_suffix}in order to make it more clear that they are reserved keywords and also it seems less redundant as the line already starts with the call to theenummethod.Cross-refs #19813 (comment).
Have a nice day.