Module: Shared::PolymorphicAnnotator
- Extended by:
- ActiveSupport::Concern
- Included in:
- AlternateValue, Attribution, Citation, Confidence, DataAttribute, Depiction, Documentation, Identifier, Label, Note, OriginRelationship, ProtocolRelationship, Role, Tag
- Defined in:
- app/models/concerns/shared/polymorphic_annotator.rb
Overview
Helper methods for polymorphic annotators. Extends annotators so that global_id strings can be used as attributes referencing the polymorphic object.
To implement:
include Shared::PolymorphicAnnotator
polymorphic_annotates('belongs_to_name', 'foreign_key')
The foreign_key argument is optional, and only necessary when it can't be derived from the belongs_to_name.
Implementing concerns, for example Shared::Taggable, should push foreign keys, like:
Tag..push self.name.foreign_key
TODO: sometime way down the line revisit this !! This should be fine when inverse_of: attributes are added !! Please DO NOT include the following:
validates :<foo>_object, presence: true
validates_presence_of :<foo>_object_type, :<foo>_object_id