Module: Shared::Citations

Extended by:
ActiveSupport::Concern
Included in:
AssertedDistribution, BiologicalAssociation, BiologicalAssociationsGraph, BiologicalRelationship, CharacterState, CollectingEvent, CollectionObject, CommonName, Confidence, Content, DataAttribute, Descriptor, Georeference, Observation, ObservationMatrix, ObservationMatrixRow, ObservationMatrixRowItem, Otu, Protocol, TaxonDetermination, TaxonName, TaxonNameClassification, TaxonNameRelationship, TypeMaterial
Defined in:
app/models/concerns/shared/citations.rb

Overview

Shared code for Citations.

The default behaviour with order by youngest source and oldest source is to place records with NIL *last*

in the list.

When multiple citations exist the earliest or latest is used in the sort order.

Instance Method Summary (collapse)

Instance Method Details

- (Boolean) cited?

Returns:

  • (Boolean)


128
129
130
# File 'app/models/concerns/shared/citations.rb', line 128

def cited?
  self.citations.any?
end

- (Object) mark_citations_for_destruction



132
133
134
# File 'app/models/concerns/shared/citations.rb', line 132

def mark_citations_for_destruction
  citations.map(&:mark_for_destruction)
end

- (Object) origin_citation_source_id



106
107
108
109
110
# File 'app/models/concerns/shared/citations.rb', line 106

def origin_citation_source_id
  if origin_citation && origin_citation.source_id.blank?
    errors.add(:base, 'the origin citation must have a source')
  end
end

- (Object) reject_citations(attributed) (protected)



138
139
140
141
# File 'app/models/concerns/shared/citations.rb', line 138

def reject_citations(attributed)
  return true if attributed['source_id'].blank? && attributed['source'].blank?
  false
end

- (Boolean) requires_citation?

Returns if at least one citation is required override this with true in including class

Returns:

  • (Boolean)

    if at least one citation is required override this with true in including class



124
125
126
# File 'app/models/concerns/shared/citations.rb', line 124

def requires_citation?
  false
end