Class: Descriptor

Inherits:
ActiveRecord::Base
  • Object
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

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?

Class Method Details

+ (Object) human_name



27
28
29
# File 'app/models/descriptor.rb', line 27

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

Instance Method Details

- (Boolean) qualitative?

Returns:

  • (Boolean)


31
32
33
# File 'app/models/descriptor.rb', line 31

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

- (Object) short_name_is_shorter (protected)



42
43
44
# File 'app/models/descriptor.rb', line 42

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)



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

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)



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

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