Class: Descriptor

Inherits:
ApplicationRecord show all
Includes:
Housekeeping, Shared::AlternateValues, Shared::Citable, Shared::Confidence, Shared::DataAttributes, Shared::Documentation, Shared::Identifiable, Shared::IsData, Shared::Notable, Shared::Taggable, SoftValidation
Defined in:
app/models/descriptor.rb

Overview

Descriptors are the general mechanism for describing CollectionObjects (individual specimens) or Otus (taxa).

They come in various types, reflecting the approaches commonly used to describe specimens and OTUs:

Working - raw notes or images, "primal" observations, not yet refined to states or measurements
Qualitative - Represents character/character_state expressions as traditionally understood.
Quantitative - Single measurements.
Sample - Summaries of multiple observations recorded in a statistical manner. Only valid for Otus. For example "length 42-77mm (n=5, min: 42, max:Only valid for Otus."

Direct Known Subclasses

Continuous, Gene, PresenceAbsence, Qualitative, Sample, Working

Defined Under Namespace

Classes: Continuous, Gene, PresenceAbsence, Qualitative, Sample, Working

Constant Summary

ALTERNATE_VALUES_FOR =
[:name, :short_name]

Constants included from SoftValidation

SoftValidation::ANCESTORS_WITH_SOFT_VALIDATIONS

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods included from SoftValidation

#clear_soft_validations, #fix_soft_validations, #soft_fixed?, #soft_valid?, #soft_validate, #soft_validated?, #soft_validations

Methods included from Housekeeping

#has_polymorphic_relationship?

Methods included from ActiverecordUtilities

#trim_attributes

Class Method Details

+ (Object) human_name



36
37
38
# File 'app/models/descriptor.rb', line 36

def self.human_name
  self.name.demodulize.humanize
end

Instance Method Details

- (Boolean) qualitative?

Returns:

  • (Boolean)


40
41
42
# File 'app/models/descriptor.rb', line 40

def qualitative?
  type == 'Descriptor::Qualitative'
end

- (Object) short_name_is_shorter (protected)



51
52
53
# File 'app/models/descriptor.rb', line 51

def short_name_is_shorter
  errors.add(:short_name, 'is longer than name!') if short_name && name && (short_name.length > name.length)
end

- (Object) sv_short_name_is_short (protected)



55
56
57
# File 'app/models/descriptor.rb', line 55

def sv_short_name_is_short
  soft_validations.add(:short_name, 'should likely be less than 12 characters long') if short_name && short_name.length > 12
end

- (Object) type_is_subclassed (protected)



45
46
47
48
49
# File 'app/models/descriptor.rb', line 45

def type_is_subclassed
  if !DESCRIPTOR_TYPES[type]
    errors.add(:type, 'type must be a valid subclass')
  end
end