-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MONGOID-5210 Prefer field :type as Symbol + custom field type symbols #5119
base: master
Are you sure you want to change the base?
MONGOID-5210 Prefer field :type as Symbol + custom field type symbols #5119
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
@p-mongo tests are now written. This is ready for final review and merge. |
…shields/mongoid into custom-field-type-support
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
@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. |
This is blocked until after #5269 is merged.
Fixes MONGOID-5210
Prior to this PR, Mongoid already supports defining field
:type
as aSymbol
rather 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.mongoize
should beMongoizers::String.mongoize(string)
.