module Mongoid::Relations::Polymorphic::ClassMethods

Public Instance Methods

polymorph(metadata) click to toggle source
# File lib/mongoid-multiple-polymorphic/mongoid/relations/polymorphic.rb, line 5
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