Module: Shared::IsData::Annotation
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/shared/is_data/annotation.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #annotation_metadata(project_id = nil) ⇒ Hash
-
#annotations ⇒ Hash
An accessor for the annotations_hash, overwritten by some inheriting classes.
-
#annotations_hash ⇒ Hash
protected
Contains all “annotations” for this instance.
- #available_annotation_types ⇒ Object
-
#has_loans? ⇒ Boolean
Doesn’t belong here.
Instance Method Details
#annotation_metadata(project_id = nil) ⇒ Hash
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'app/models/concerns/shared/is_data/annotation.rb', line 71 def (project_id = nil) h = {} # Use a fixed order for UI stability ANNOTATION_TYPES.each do |t| next unless available_annotation_types.include?(t) case t when :documentation if project_id h[:documentation] = {total: documentation.where(documentation: {project_id:}).count} else h[:documentation] = {total: ( send(:documentation).count) } end when :attribution h[:attribution] = {total: (send(:attribution).present? ? 1 : 0)} when :identifiers if project_id h[:identifiers] = {total: ( send(:identifiers).visible(project_id).count)} else h[:identifiers] = {total: ( send(:identifiers).count) } end else h[t] = { total: send(t).count } end end h end |
#annotations ⇒ Hash
Returns an accessor for the annotations_hash, overwritten by some inheriting classes.
66 67 68 |
# File 'app/models/concerns/shared/is_data/annotation.rb', line 66 def annotations annotations_hash end |
#annotations_hash ⇒ Hash (protected)
Contains all “annotations” for this instance
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'app/models/concerns/shared/is_data/annotation.rb', line 106 def annotations_hash result = {} result['citations'] = citations if has_citations? && citations.load.any? # Use load since we nearly always are going ot reference the result result['data attributes'] = data_attributes if has_data_attributes? && data_attributes.load.any? result['identifiers'] = identifiers if has_identifiers? && identifiers.load.any? # !! TODO: Load is broken here. result['notes'] = notes if has_notes? && notes.load.any? result['tags'] = if && .load.any? result['depictions'] = depictions.order('depictions.position') if has_depictions? && depictions.load.any? result['confidences'] = confidences if has_confidences? && confidences.load.any? result['protocol relationships'] = protocols if has_protocol_relationships? && protocolled? result['alternate values'] = alternate_values if has_alternate_values? && alternate_values.load.any? result['attribution'] = attribution if has_attribution? && attribution.load.any? result['verifiers'] = verifiers if has_verifiers? && verifiers.load.any? result end |
#available_annotation_types ⇒ Object
53 54 55 56 57 |
# File 'app/models/concerns/shared/is_data/annotation.rb', line 53 def available_annotation_types ::ANNOTATION_TYPES.select do |a| self.send("has_#{a}?") end end |