Module: Mongoid::Relations::Polymorphic::ClassMethods
- Defined in:
- lib/mongoid/relations/polymorphic.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#polymorph(metadata) ⇒ Class
Attempts to set up the information needed to handle a polymorphic relation, if the metadata checks out.
-
#polymorphic? ⇒ true, false
Determines if the class is in a polymorphic relations, and thus must store the _type field in the database.
Instance Method Details
#polymorph(metadata) ⇒ Class
Attempts to set up the information needed to handle a polymorphic relation, if the metadata checks out.
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/mongoid/relations/polymorphic.rb', line 28 def polymorph() tap do |klass| if .polymorphic? klass.polymorphic = true if .relation.stores_foreign_key? field(.inverse_type, :type => String) end end end end |
#polymorphic? ⇒ true, false
Determines if the class is in a polymorphic relations, and thus must store the _type field in the database.
48 49 50 |
# File 'lib/mongoid/relations/polymorphic.rb', line 48 def polymorphic? !!polymorphic end |