Module: Shared::Tags

Extended by:
ActiveSupport::Concern
Included in:
AssertedDistribution, BiocurationClass, BiologicalAssociation, BiologicalRelationship, CharacterState, Citation, CollectingEvent, CollectionObject, CollectionObjectObservation, CollectionProfile, CommonName, Container, Depiction, Descriptor, Document, Documentation, GeneAttribute, Georeference, Image, Loan, LoanItem, Note, Observation, ObservationMatrix, ObservationMatrixColumn, ObservationMatrixColumnItem, ObservationMatrixRow, ObservationMatrixRowItem, Otu, PreparationType, Sequence, SequenceRelationship, Serial, Source, SqedDepiction, TaxonName, Topic, TypeMaterial, User
Defined in:
app/models/concerns/shared/tags.rb

Overview

Shared code for extending data classes with Tags.

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary (collapse)

Instance Method Details

- (Object) reject_tags(attributed) (private)



61
62
63
64
65
# File 'app/models/concerns/shared/tags.rb', line 61

def reject_tags(attributed)
  (attributed['keyword'].blank? && attributed['keyword_id'].blank?) &&
    attributed['position'].blank? &&
    attributed['keyword_attributes'].blank?
end

- (Object) tag_with(keyword_id)



45
46
47
# File 'app/models/concerns/shared/tags.rb', line 45

def tag_with(keyword_id)
  tags << Tag.new(keyword_id: keyword_id)
end

- (Boolean) tagged?

Returns true if the object has tags

Returns:

  • (Boolean)

    true if the object has tags



35
36
37
# File 'app/models/concerns/shared/tags.rb', line 35

def tagged?
  tags.any?
end

- (Boolean) tagged_with?(keyword_id)

Returns true if the object has a tak with this keyword

Returns:

  • (Boolean)

    true if the object has a tak with this keyword



41
42
43
# File 'app/models/concerns/shared/tags.rb', line 41

def tagged_with?(keyword_id)
  tags.where(keyword_id: keyword_id).any?
end