Module: Shared::Tags
- Extended by:
- ActiveSupport::Concern
- Included in:
- AnatomicalPart, AssertedDistribution, Attribution, BiocurationClass, BiologicalAssociation, BiologicalAssociationsGraph, BiologicalRelationship, CharacterState, Citation, CollectingEvent, CollectionObject, CollectionObjectObservation, CollectionProfile, CommonName, Container, Conveyance, Depiction, Descriptor, Document, Documentation, Extract, FieldOccurrence, GeneAttribute, Georeference, Image, Label, Lead, Loan, LoanItem, Note, Observation, ObservationMatrix, ObservationMatrixColumnItem, ObservationMatrixRowItem, Otu, OtuRelationship, Person, PreparationType, Repository, Sequence, SequenceRelationship, Serial, SledImage, Sound, 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
- #reject_tags(attributed) ⇒ Object private
- #tag_with(keyword_id) ⇒ Object
-
#tagged? ⇒ Boolean
True if the object has tags.
-
#tagged_with?(keyword_id) ⇒ Boolean
True if the object has a tak with this keyword.
Instance Method Details
#reject_tags(attributed) ⇒ Object (private)
52 53 54 55 56 |
# File 'app/models/concerns/shared/tags.rb', line 52 def (attributed) (attributed['keyword'].blank? && attributed['keyword_id'].blank?) && attributed['position'].blank? && attributed['keyword_attributes'].blank? end |
#tag_with(keyword_id) ⇒ Object
31 32 33 |
# File 'app/models/concerns/shared/tags.rb', line 31 def tag_with(keyword_id) << Tag.new(keyword_id:) end |
#tagged? ⇒ Boolean
Returns true if the object has tags.
21 22 23 |
# File 'app/models/concerns/shared/tags.rb', line 21 def tagged? .any? end |
#tagged_with?(keyword_id) ⇒ Boolean
Returns true if the object has a tak with this keyword.
27 28 29 |
# File 'app/models/concerns/shared/tags.rb', line 27 def tagged_with?(keyword_id) .where(keyword_id:).any? end |