Module: Mongoid::Fields::Mappings
Overview
This module maps classes used in field type definitions to the custom definable field in Mongoid.
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.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/mongoid/fields/mappings.rb', line 24 def for(klass, foreign_key = false) if klass.nil? Internal::Object elsif foreign_key Internal::ForeignKeys.const_get(klass.to_s) else modules = "BSON::|ActiveSupport::" match = klass.to_s.match(Regexp.new("^(#{ modules })?(\\w+)$")) if match and Internal.const_defined?(match[2]) Internal.const_get(match[2]) else klass end end end |