MONGOID-5210 Prefer field :type as Symbol + custom field type symbols#5119
Open
johnnyshields wants to merge 17 commits intomongodb:masterfrom
Open
MONGOID-5210 Prefer field :type as Symbol + custom field type symbols#5119johnnyshields wants to merge 17 commits intomongodb:masterfrom
johnnyshields wants to merge 17 commits intomongodb:masterfrom
Conversation
b231317 to
4717986
Compare
…Symbol is already supported today.) - Deprecate using field type as a Class. - Add ability to define custom field types using a mini DSL (Mongoid::Fields.configure) - Fix Mongoid::Fields.option documentation
ebdaaba to
22222c6
Compare
Contributor
Author
|
@p-mongo tests are now written. This is ready for final review and merge. |
…shields/mongoid into custom-field-type-support
p-mongo
suggested changes
May 9, 2022
Contributor
p-mongo
left a comment
There was a problem hiding this comment.
Hi @johnnyshields ,
The portion of this PR that we can merge is the one described in https://jira.mongodb.org/browse/MONGOID-5336 which is permitting applications to define their own aliases. Can you please remove from the diff the changes that have to do with replacing class use with symbol use?
Contributor
Author
|
@p-mongo I will be happy to split out that code soon. However, please see my reply in https://jira.mongodb.org/browse/MONGOID-5210, in the future, I still believe there is strong justification to switch to symbols. |
Contributor
Author
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.
This is blocked until after #5269 is merged.
Fixes MONGOID-5210
Prior to this PR, Mongoid already supports defining field
:typeas aSymbolrather than aClass:Generally speaking, it is much better to to use Symbol than Class, because Class uses autoloading etc.
This PR adds the following:
Further Plans
In Mongoid 8.1+, once everything is symbols we should consider extracting out the mongoization logic into separate modules and not inserting methods into Ruby Kernel classes. For example,
String.mongoizeshould beMongoizers::String.mongoize(string).