Module: Shared::BiologicalAssociations

Extended by:
ActiveSupport::Concern
Included in:
Otu
Defined in:
app/models/concerns/shared/biological_associations.rb

Overview

Shared code for extending data classes to be referencable in a BiologicalAssociation

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#all_biological_associationsArray

!! If self relationships are ever made possible this needs a DISTINCT clause

Returns:

  • (Array)

    all bilogical associations this Otu is part of



22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/models/concerns/shared/biological_associations.rb', line 22

def all_biological_associations
  BiologicalAssociation.find_by_sql(
    "SELECT biological_associations.*
      FROM biological_associations
      WHERE biological_associations.biological_association_subject_id = #{id}
        AND biological_associations.biological_association_subject_type = '#{self.class.base_class.name}'
    UNION
    SELECT biological_associations.*
      FROM biological_associations
      WHERE biological_associations.biological_association_object_id = #{id}
        AND biological_associations.biological_association_object_type = '#{self.class.base_class.name}'")
end