Module: Shared::Citable

Extended by:
ActiveSupport::Concern
Included in:
AssertedDistribution, BiologicalAssociation, BiologicalAssociationsGraph, BiologicalRelationship, CollectingEvent, CollectionObject, Combination, CommonName, Georeference, Otu, TaxonDetermination, TaxonName, TaxonNameClassification, TaxonNameRelationship, TypeMaterial
Defined in:
app/models/concerns/shared/citable.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)


114
115
116
# File 'app/models/concerns/shared/citable.rb', line 114

def cited?
  self.citations.any?
end

- (Object) mark_citations_for_destruction



118
119
120
# File 'app/models/concerns/shared/citable.rb', line 118

def mark_citations_for_destruction
  citations.map(&:mark_for_destruction)
end

- (Object) origin_citation_source_id



92
93
94
95
96
# File 'app/models/concerns/shared/citable.rb', line 92

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)



124
125
126
127
128
129
# File 'app/models/concerns/shared/citable.rb', line 124

def reject_citations(attributed)
  return true if attributed['source_id'].blank? && attributed['source'].blank?
  if !new_record?
    return true if attributed['id'].blank?
  end
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



110
111
112
# File 'app/models/concerns/shared/citable.rb', line 110

def requires_citation?
  false
end