Module: Mongoid::Relations::Polymorphic::ClassMethods

Defined in:
lib/mongoid-multiple-polymorphic/mongoid/relations/polymorphic.rb

Instance Method Summary collapse

Instance Method Details

#polymorph(metadata) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/mongoid-multiple-polymorphic/mongoid/relations/polymorphic.rb', line 5

def polymorph()
  if .polymorphic?
    self.polymorphic = true
    if .relation.stores_foreign_key?
      field(.inverse_type, type: String)
      field(.inverse_of_field, type: Symbol)
    end
  end
  self
end