Module: Mongoid::Fields::Mappings
Overview
This module maps classes used in field type definitions to the custom definable field in Mongoid.
Constant Summary collapse
- MODULE =
"Mongoid::Fields::Serializable"
Instance Method Summary collapse
-
#for(klass, foreign_key = false) ⇒ Class
Get the custom field type for the provided class used in the field definition.
Instance Method Details
#for(klass, foreign_key = false) ⇒ Class
Get the custom field type for the provided class used in the field definition.
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/mongoid/fields/mappings.rb', line 23 def for(klass, foreign_key = false) return Serializable::Object unless klass if foreign_key return "#{MODULE}::ForeignKeys::#{klass.to_s.demodulize}".constantize end begin "#{MODULE}::#{klass.to_s.demodulize}".constantize rescue NameError klass end end |