Class: ObservationMatrixRowItem::Dynamic::Tag
- Inherits:
-
ObservationMatrixRowItem::Dynamic
- Object
- ObservationMatrixRowItem::Dynamic
- ObservationMatrixRowItem::Dynamic::Tag
- Defined in:
- app/models/observation_matrix_row_item/dynamic/tag.rb
Instance Method Summary collapse
- #keyword_is_unique ⇒ Object private
- #matrix_row_item_object ⇒ Object
- #observation_objects ⇒ Object
- #value_of_observation_object_type ⇒ Object private
Instance Method Details
#keyword_is_unique ⇒ Object (private)
20 21 22 23 24 25 |
# File 'app/models/observation_matrix_row_item/dynamic/tag.rb', line 20 def keyword_is_unique errors.add(:observation_object, 'is already taken') if ObservationMatrixRowItem::Dynamic::Tag.where.not(id: id).where( observation_object: observation_object, observation_matrix_id: observation_matrix_id ).any? end |
#matrix_row_item_object ⇒ Object
14 15 16 |
# File 'app/models/observation_matrix_row_item/dynamic/tag.rb', line 14 def matrix_row_item_object controlled_vocabulary_term end |
#observation_objects ⇒ Object
6 7 8 9 10 11 12 |
# File 'app/models/observation_matrix_row_item/dynamic/tag.rb', line 6 def observation_objects d = [] OBSERVABLE_TYPES.each do |t| # Currently assumes all types are may be tagged, could do a simple check d += t.safe_constantize.joins(:tags).where(tags: {keyword: observation_object}).to_a end d end |
#value_of_observation_object_type ⇒ Object (private)
27 28 29 |
# File 'app/models/observation_matrix_row_item/dynamic/tag.rb', line 27 def value_of_observation_object_type errors.add(:observation_object) if observation_object_type != 'ControlledVocabularyTerm' end |