Module: Shared::Tags
- Extended by:
- ActiveSupport::Concern
- Included in:
- AssertedDistribution, Attribution, BiocurationClass, BiologicalAssociation, BiologicalAssociationsGraph, BiologicalRelationship, CharacterState, Citation, CollectionObjectObservation, CollectionProfile, CommonName, Container, Depiction, Descriptor, Document, Documentation, Extract, GeneAttribute, Georeference, Image, Label, Loan, LoanItem, Note, Observation, ObservationMatrixColumn, ObservationMatrixColumnItem, ObservationMatrixRow, ObservationMatrixRowItem, Otu, Person, PreparationType, Repository, Sequence, SequenceRelationship, Serial, SledImage, Source, SqedDepiction, 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)
65 66 67 68 69 |
# File 'app/models/concerns/shared/tags.rb', line 65 def (attributed) (attributed['keyword'].blank? && attributed['keyword_id'].blank?) && attributed['position'].blank? && attributed['keyword_attributes'].blank? end |
#tag_with(keyword_id) ⇒ Object
45 46 47 |
# File 'app/models/concerns/shared/tags.rb', line 45 def tag_with(keyword_id) << Tag.new(keyword_id: keyword_id) end |
#tagged? ⇒ Boolean
Returns true if the object has tags.
35 36 37 |
# File 'app/models/concerns/shared/tags.rb', line 35 def tagged? .any? end |
#tagged_with?(keyword_id) ⇒ Boolean
Returns 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) .where(keyword_id: keyword_id).any? end |