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)

Instance Method Details

- (Hash) annotation_metadata

Returns:

  • (Hash)


55
56
57
# File 'app/models/concerns/shared/is_data/annotation.rb', line 55

def 
  available_annotation_types.inject({}){|hsh, a| hsh.merge!(a => {total: send(a).count})}
end

- (#annotations_hash) annotations

Returns an accessor for the annotations_hash, overwritten by some inheriting classes

Returns:

  • (#annotations_hash)

    an accessor for the annotations_hash, overwritten by some inheriting classes



44
45
46
# File 'app/models/concerns/shared/is_data/annotation.rb', line 44

def annotations
  annotations_hash
end

- (Hash) annotations_hash (protected)

Contains all “annotations” for this instance

Returns:

  • (Hash)


63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'app/models/concerns/shared/is_data/annotation.rb', line 63

def annotations_hash
  result = {}
  result['citations'] = citations if has_citations? && citations.any?
  result['data attributes'] = data_attributes if has_data_attributes? && data_attributes.any?
  result['identifiers'] = identifiers if has_identifiers? && identifiers.any?
  result['notes'] = notes if has_notes? && notes.any?
  result['tags'] = tags if has_tags? && tags.any?
  result['depictions'] = depictions.order('depictions.position') if has_depictions? && depictions.any?
  result['confidences'] = confidences if has_confidences? && confidences.any?
  result['protocol_relationships'] = protocols if has_protocol_relationships? && protocolled?
  result['alternate values'] = alternate_values if has_alternate_values? && alternate_values.any?
  result
end

- (Object) available_annotation_types



48
49
50
51
52
# File 'app/models/concerns/shared/is_data/annotation.rb', line 48

def available_annotation_types
  ::ANNOTATION_TYPES.select do |a|
    self.send("has_#{a}?")
  end
end

- (Boolean) has_loans?

Returns:

  • (Boolean)


38
39
40
# File 'app/models/concerns/shared/is_data/annotation.rb', line 38

def has_loans?
  self.class < Shared::Loanable ? true : false
end