module Mongoid::Relations::Polymorphic::ClassMethods
Public Instance Methods
polymorph(metadata)
click to toggle source
Attempts to set up the information needed to handle a polymorphic relation, if the metadata checks out.
@example Set up the polymorphic information.
Movie.polymorph(metadata)
@param [ Metadata ] metadata The relation metadata.
@return [ Class ] The class being set up.
@since 2.0.0.rc.1
# File lib/mongoid/relations/polymorphic.rb, line 26 def polymorph(metadata) if metadata.polymorphic? self.polymorphic = true if metadata.relation.stores_foreign_key? field(metadata.inverse_type, type: String) field(metadata.inverse_of_field, type: Symbol) end end self end