Module: Shared::PolymorphicAnnotator

Extended by:
ActiveSupport::Concern
Included in:
AlternateValue, Attribution, Citation, Confidence, DataAttribute, Depiction, Documentation, Identifier, Label, Note, ProtocolRelationship, 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.related_foreign_keys.push self.name.foreign_key

TODO: sometime way down the line revisit this Please DO NOT include the following:

validates :<foo>_object, presence: true
validates_presence_of :<foo>_object_type, :<foo>_object_id