-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Prefer defining field type value as a Symbol rather than a Class. (…
…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)
- Loading branch information
1 parent
da48cea
commit 4717986
Showing
8 changed files
with
297 additions
and
85 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# frozen_string_literal: true | ||
|
||
module Mongoid | ||
module Errors | ||
|
||
# This error is raised when trying to define a field using a :type option value | ||
# that is not present in the field type mapping. | ||
class InvalidFieldType < MongoidError | ||
|
||
# Create the new error. | ||
# | ||
# @example Instantiate the error. | ||
# InvalidFieldType.new('Person', 'first_name', 'stringgy') | ||
# | ||
# @param [ String ] klass The model class. | ||
# @param [ String ] field The field on which the invalid type is used. | ||
# @param [ String ] type The value of the field :type option. | ||
def initialize(klass, field, type) | ||
super( | ||
compose_message('invalid_field_type', { klass: klass, field: field, type: type }) | ||
) | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.